home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 15 / CU Amiga Magazine's Super CD-ROM 15 (1997)(EMAP Images)(GB)[!][issue 1997-10].iso / CUCD / Graphics / Ghostscript / source / libpng / png.h < prev    next >
Encoding:
C/C++ Source or Header  |  1997-05-16  |  80.4 KB  |  1,836 lines

  1.  
  2. /* png.h - header file for PNG reference library
  3.  
  4.    libpng 1.0 beta 6 - version 0.96
  5.    For conditions of distribution and use, see copyright notice in png.h
  6.    Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
  7.    Copyright (c) 1996, 1997 Andreas Dilger
  8.    May 12, 1997
  9.  
  10.    BETA NOTICE:
  11.       This is a beta version.  It reads and writes valid files on the
  12.       platforms I have, and has had a wide testing program.  You may
  13.       have to modify the includes below to get it to work on your
  14.       system, and you may have to supply the correct compiler flags in
  15.       the makefile if you can't find a makefile suitable for your
  16.       operating system/compiler combination.  Read libpng.txt for more
  17.       information, including how to contact the authors if you have any
  18.       problems, or if you want your compiler/platform to be supported in
  19.       the next official libpng release.
  20.  
  21.    See libpng.txt for more information.
  22.  
  23.    Contributing Authors:
  24.       John Bowler
  25.       Sam Bushell
  26.       Kevin Bracey
  27.       Andreas Dilger
  28.       Magnus Holmgren
  29.       Dave Martindale
  30.       Greg Roelofs
  31.       Guy Eric Schalnat
  32.       Paul Schmidt
  33.       Tom Tanner
  34.       Tim Wegner
  35.  
  36.    The contributing authors would like to thank all those who helped
  37.    with testing, bug fixes, and patience.  This wouldn't have been
  38.    possible without all of you.
  39.  
  40.    Thanks to Frank J. T. Wojcik for helping with the documentation.
  41.  
  42.    The PNG Reference Library is supplied "AS IS".  The Contributing Authors
  43.    and Group 42, Inc. disclaim all warranties, expressed or implied,
  44.    including, without limitation, the warranties of merchantability and of
  45.    fitness for any purpose.  The Contributing Authors and Group 42, Inc.
  46.    assume no liability for direct, indirect, incidental, special, exemplary,
  47.    or consequential damages, which may result from the use of the PNG
  48.    Reference Library, even if advised of the possibility of such damage.
  49.  
  50.    Permission is hereby granted to use, copy, modify, and distribute this
  51.    source code, or portions hereof, for any purpose, without fee, subject
  52.    to the following restrictions:
  53.    1. The origin of this source code must not be misrepresented.
  54.    2. Altered versions must be plainly marked as such and must not be
  55.       misrepresented as being the original source.
  56.    3. This Copyright notice may not be removed or altered from any source or
  57.       altered source distribution.
  58.  
  59.    The Contributing Authors and Group 42, Inc. specifically permit, without
  60.    fee, and encourage the use of this source code as a component to
  61.    supporting the PNG file format in commercial products.  If you use this
  62.    source code in a product, acknowledgment is not required but would be
  63.    appreciated.
  64. */
  65.  
  66. #ifndef _PNG_H
  67. #define _PNG_H
  68.  
  69. #ifdef __cplusplus
  70. extern "C" {
  71. #endif /* __cplusplus */
  72.  
  73. /* This is not the place to learn how to use libpng.  The file libpng.txt
  74.  * describes how to use libpng, and the file example.c summarizes it
  75.  * with some code on which to build.  This file is useful for looking
  76.  * at the actual function definitions and structure components.
  77.  */
  78.  
  79. /* include the compression library's header */
  80. #include "zlib.h"
  81.  
  82. /* include all user configurable info */
  83. #include "pngconf.h"
  84.  
  85. /* This file is arranged in several sections.  The first section contains
  86.  * structure and type definitions.  The second section contains the external
  87.  * library functions, while the third has the internal library functions,
  88.  * which applications aren't expected to use directly.
  89.  */
  90.  
  91. /* Version information for png.h - this should match the version in png.c */
  92. #define PNG_LIBPNG_VER_STRING "0.96"
  93.  
  94. /* careful here.  At one time, I wanted to use 082, but that would be octal.
  95.  * Version 1.0 will be 100 here, etc.
  96.  */
  97. #define PNG_LIBPNG_VER 96
  98.  
  99. /* variables declared in png.c - only it needs to define PNG_NO_EXTERN */
  100. #ifndef PNG_NO_EXTERN
  101. /* Version information for C files, stored in png.c.  This had better match
  102.  * the version above.
  103.  */
  104. extern char png_libpng_ver[];
  105.  
  106. /* Structures to facilitate easy interlacing.  See png.c for more details */
  107. extern int FARDATA png_pass_start[];
  108. extern int FARDATA png_pass_inc[];
  109. extern int FARDATA png_pass_ystart[];
  110. extern int FARDATA png_pass_yinc[];
  111. extern int FARDATA png_pass_mask[];
  112. extern int FARDATA png_pass_dsp_mask[];
  113. /* These aren't currently used.  If you need them, see png.c for more details
  114. extern int FARDATA png_pass_width[];
  115. extern int FARDATA png_pass_height[];
  116. */
  117. #endif /* PNG_NO_EXTERN */
  118.  
  119. /* Three color definitions.  The order of the red, green, and blue, (and the
  120.  * exact size) is not important, although the size of the fields need to
  121.  * be png_byte or png_uint_16 (as defined below).
  122.  */
  123. typedef struct png_color_struct
  124. {
  125.    png_byte red;
  126.    png_byte green;
  127.    png_byte blue;
  128. } png_color;
  129. typedef png_color FAR * png_colorp;
  130. typedef png_color FAR * FAR * png_colorpp;
  131.  
  132. typedef struct png_color_16_struct
  133. {
  134.    png_byte index;    /* used for palette files */
  135.    png_uint_16 red;   /* for use in red green blue files */
  136.    png_uint_16 green;
  137.    png_uint_16 blue;
  138.    png_uint_16 gray;  /* for use in grayscale files */
  139. } png_color_16;
  140. typedef png_color_16 FAR * png_color_16p;
  141. typedef png_color_16 FAR * FAR * png_color_16pp;
  142.  
  143. typedef struct png_color_8_struct
  144. {
  145.    png_byte red;   /* for use in red green blue files */
  146.    png_byte green;
  147.    png_byte blue;
  148.    png_byte gray;  /* for use in grayscale files */
  149.    png_byte alpha; /* for alpha channel files */
  150. } png_color_8;
  151. typedef png_color_8 FAR * png_color_8p;
  152. typedef png_color_8 FAR * FAR * png_color_8pp;
  153.  
  154. /* png_text holds the text in a PNG file, and whether they are compressed
  155.    in the PNG file or not.  The "text" field points to a regular C string. */
  156. typedef struct png_text_struct
  157. {
  158.    int compression;        /* compression value, see PNG_TEXT_COMPRESSION_ */
  159.    png_charp key;          /* keyword, 1-79 character description of "text" */
  160.    png_charp text;         /* comment, may be an empty string (ie "") */
  161.    png_size_t text_length; /* length of "text" field */
  162. } png_text;
  163. typedef png_text FAR * png_textp;
  164. typedef png_text FAR * FAR * png_textpp;
  165.  
  166. /* Supported compression types for text in PNG files (tEXt, and zTXt).
  167.  * The values of the PNG_TEXT_COMPRESSION_ defines should NOT be changed. */
  168. #define PNG_TEXT_COMPRESSION_NONE_WR -3
  169. #define PNG_TEXT_COMPRESSION_zTXt_WR -2
  170. #define PNG_TEXT_COMPRESSION_NONE    -1
  171. #define PNG_TEXT_COMPRESSION_zTXt     0
  172. #define PNG_TEXT_COMPRESSION_LAST     1  /* Not a valid value */
  173.  
  174. /* png_time is a way to hold the time in an machine independent way.
  175.    Two conversions are provided, both from time_t and struct tm.  There
  176.    is no portable way to convert to either of these structures, as far
  177.    as I know.  If you know of a portable way, send it to me.  As a side
  178.    note - PNG is Year 2000 compliant! */
  179. typedef struct png_time_struct
  180. {
  181.    png_uint_16 year; /* full year, as in, 1995 */
  182.    png_byte month;   /* month of year, 1 - 12 */
  183.    png_byte day;     /* day of month, 1 - 31 */
  184.    png_byte hour;    /* hour of day, 0 - 23 */
  185.    png_byte minute;  /* minute of hour, 0 - 59 */
  186.    png_byte second;  /* second of minute, 0 - 60 (for leap seconds) */
  187. } png_time;
  188. typedef png_time FAR * png_timep;
  189. typedef png_time FAR * FAR * png_timepp;
  190.  
  191. /* png_info is a structure that holds the information in a PNG file so
  192.  * that the application can find out the characteristics of the image.
  193.  * If you are reading the file, this structure will tell you what is
  194.  * in the PNG file.  If you are writing the file, fill in the information
  195.  * you want to put into the PNG file, then call png_write_info().
  196.  * The names chosen should be very close to the PNG specification, so
  197.  * consult that document for information about the meaning of each field.
  198.  *
  199.  * With libpng < 0.95, it was only possible to directly set and read the
  200.  * the values in the png_info_struct, which meant that the contents and
  201.  * order of the values had to remain fixed.  With libpng 0.95 and later,
  202.  * however, * there are now functions which abstract the contents of
  203.  * png_info_struct from the application, so this makes it easier to use
  204.  * libpng with dynamic libraries, and even makes it possible to use
  205.  * libraries that don't have all of the libpng ancillary chunk-handing
  206.  * functionality.
  207.  *
  208.  * In any case, the order of the parameters in png_info_struct should NOT
  209.  * be changed for as long as possible to keep compatibility with applications
  210.  * that use the old direct-access method with png_info_struct.
  211.  */
  212. typedef struct png_info_struct
  213. {
  214.    /* the following are necessary for every PNG file */
  215.    png_uint_32 width;       /* width of image in pixels (from IHDR) */
  216.    png_uint_32 height;      /* height of image in pixels (from IHDR) */
  217.    png_uint_32 valid;       /* valid chunk data (see PNG_INFO_ below) */
  218.    png_size_t rowbytes;     /* bytes needed to hold an untransformed row */
  219.    png_colorp palette;      /* array of color values (valid & PNG_INFO_PLTE) */
  220.    png_uint_16 num_palette; /* number of color entries in "palette" (PLTE) */
  221.    png_uint_16 num_trans;   /* number of transparent palette color (tRNS) */
  222.    png_byte bit_depth;      /* 1, 2, 4, 8, or 16 bits/channel (from IHDR) */
  223.    png_byte color_type;     /* see PNG_COLOR_TYPE_ below (from IHDR) */
  224.    png_byte compression_type; /* must be PNG_COMPRESSION_TYPE_BASE (IHDR) */
  225.    png_byte filter_type;    /* must be PNG_FILTER_TYPE_BASE (from IHDR) */
  226.    png_byte interlace_type; /* One of PNG_INTERLACE_NONE, PNG_INTERLACE_ADAM7 */
  227.  
  228.    /* The following is informational only on read, and not used on writes. */
  229.    png_byte channels;       /* number of data channels per pixel (1, 3, 4)*/
  230.    png_byte pixel_depth;    /* number of bits per pixel */
  231.    png_byte spare_byte;     /* to align the data, and for future use */
  232.    png_byte signature[8];   /* magic bytes read by libpng from start of file */
  233.  
  234.    /* The rest of the data is optional.  If you are reading, check the
  235.     * valid field to see if the information in these are valid.  If you
  236.     * are writing, set the valid field to those chunks you want written,
  237.     * and initialize the appropriate fields below.
  238.     */
  239.  
  240. #if defined(PNG_READ_gAMA_SUPPORTED) || defined(PNG_WRITE_gAMA_SUPPORTED)
  241.    /* The gAMA chunk describes the gamma characteristics of the system
  242.     * on which the image was created, normally in the range [1.0, 2.5].
  243.     * Data is valid if (valid & PNG_INFO_gAMA) is non-zero.
  244.     */
  245.    float gamma; /* gamma value of image, if (valid & PNG_INFO_gAMA) */
  246. #endif /* PNG_READ_gAMA_SUPPORTED || PNG_WRITE_gAMA_SUPPORTED */
  247. #if defined(PNG_READ_tEXt_SUPPORTED) || defined(PNG_WRITE_tEXt_SUPPORTED) || \
  248.     defined(PNG_READ_zTXt_SUPPORTED) || defined(PNG_WRITE_zTXt_SUPPORTED)
  249.    /* The tEXt and zTXt chunks contain human-readable textual data in
  250.     * uncompressed and compressed forms, respectively.  The data in "text"
  251.     * is an array of pointers to uncompressed, null-terminated C strings.
  252.     * Each chunk has a keyword which describes the textual data contained
  253.     * in that chunk.  Keywords are not required to be unique, and the text
  254.     * string may be empty.  Any number of text chunks may be in an image.
  255.     */
  256.    int num_text; /* number of comments read/to write */
  257.    int max_text; /* current size of text array */
  258.    png_textp text; /* array of comments read/to write */
  259. #endif /* PNG_READ_tEXt/zTXt_SUPPORTED || PNG_WRITE_tEXt/zTXt_SUPPORTED */
  260. #if defined(PNG_READ_tIME_SUPPORTED) || defined(PNG_WRITE_tIME_SUPPORTED)
  261.    /* The tIME chunk holds the last time the displayed image data was
  262.     * modified.  See the png_time struct for the contents of this struct.
  263.     */
  264.    png_time mod_time;
  265. #endif /* PNG_READ_tIME_SUPPORTED || PNG_WRITE_tIME_SUPPORTED */
  266. #if defined(PNG_READ_sBIT_SUPPORTED) || defined(PNG_WRITE_sBIT_SUPPORTED)
  267.    /* The sBIT chunk specifies the number of significant high-order bits
  268.     * in the pixel data.  Values are in the range [1, bit_depth], and are
  269.     * only specified for the channels in the pixel data.  The contents of
  270.     * the low-order bits is not specified.  Data is valid if
  271.     * (valid & PNG_INFO_sBIT) is non-zero.
  272.     */
  273.    png_color_8 sig_bit; /* significant bits in color channels */
  274. #endif /* PNG_READ_sBIT_SUPPORTED || PNG_WRITE_sBIT_SUPPORTED */
  275. #if defined(PNG_READ_tRNS_SUPPORTED) || defined(PNG_WRITE_tRNS_SUPPORTED)
  276.    /* The tRNS chunk supplies transparency data for paletted images and
  277.     * other image types that don't need a full alpha channel.  There are
  278.     * "num_trans" transparency values for a paletted image, stored in the
  279.     * same order as the palette colors, starting from index 0.  Values
  280.     * for the data are in the range [0, 255], ranging from fully transparent
  281.     * to fully opaque, respectively.  For non-paletted images, there is a
  282.     * single color specified which should be treated as fully transparent.
  283.     * Data is valid if (valid & PNG_INFO_tRNS) is non-zero.
  284.     */
  285.    png_bytep trans; /* transparent values for paletted image */
  286.    png_color_16 trans_values; /* transparent color for non-palette image */
  287. #endif /* PNG_READ_tRNS_SUPPORTED || PNG_WRITE_tRNS_SUPPORTED */
  288. #if defined(PNG_READ_bKGD_SUPPORTED) || defined(PNG_WRITE_bKGD_SUPPORTED)
  289.    /* The bKGD chunk gives the suggested image background color if the
  290.     * display program does not have its own background color and the image
  291.     * is needs to composited onto a background before display.  The colors
  292.     * in "background" are normally in the same color space/depth as the
  293.     * pixel data.  Data is valid if (valid & PNG_INFO_bKGD) is non-zero.
  294.     */
  295.    png_color_16 background;
  296. #endif /* PNG_READ_bKGD_SUPPORTED || PNG_WRITE_bKGD_SUPPORTED */
  297. #if defined(PNG_READ_oFFs_SUPPORTED) || defined(PNG_WRITE_oFFs_SUPPORTED)
  298.    /* The oFFs chunk gives the offset in "offset_unit_type" units rightwards
  299.     * and downwards from the top-left corner of the display, page, or other
  300.     * application-specific co-ordinate space.  See the PNG_OFFSET_ defines
  301.     * below for the unit types.  Valid if (valid & PNG_INFO_oFFs) non-zero.
  302.     */
  303.    png_uint_32 x_offset; /* x offset on page */
  304.    png_uint_32 y_offset; /* y offset on page */
  305.    png_byte offset_unit_type; /* offset units type */
  306. #endif /* PNG_READ_oFFs_SUPPORTED || PNG_WRITE_oFFs_SUPPORTED */
  307. #if defined(PNG_READ_pHYs_SUPPORTED) || defined(PNG_WRITE_pHYs_SUPPORTED)
  308.    /* The pHYs chunk gives the physical pixel density of the image for
  309.     * display or printing in "phys_unit_type" units (see PNG_RESOLUTION_
  310.     * defines below).  Data is valid if (valid & PNG_INFO_pHYs) is non-zero.
  311.     */
  312.    png_uint_32 x_pixels_per_unit; /* horizontal pixel density */
  313.    png_uint_32 y_pixels_per_unit; /* vertical pixel density */
  314.    png_byte phys_unit_type; /* resolution type (see PNG_RESOLUTION_ below) */
  315. #endif /* PNG_READ_pHYs_SUPPORTED || PNG_WRITE_pHYs_SUPPORTED */
  316. #if defined(PNG_READ_hIST_SUPPORTED) || defined(PNG_WRITE_hIST_SUPPORTED)
  317.    /* The hIST chunk contains the relative frequency or importance of the
  318.     * various palette entries, so that a viewer can intelligently select a
  319.     * reduced-color palette, if required.  Data is an array of "num_palette"
  320.     * values in the range [0,65535]. Data valid if (valid & PNG_INFO_hIST)
  321.     * is non-zero.
  322.     */
  323.    png_uint_16p hist;
  324. #endif /* PNG_READ_hIST_SUPPORTED || PNG_WRITE_hIST_SUPPORTED */
  325. #if defined(PNG_READ_cHRM_SUPPORTED) || defined(PNG_WRITE_cHRM_SUPPORTED)
  326.    /* The cHRM chunk describes the CIE color characteristics of the monitor
  327.     * on which the PNG was created.  This data allows the viewer to do gamut
  328.     * mapping of the input image to ensure that the viewer sees the same
  329.     * colors in the image as the creator.  Values are in the range
  330.     * [0.0, 0.8].  Data valid if (valid & PNG_INFO_cHRM) non-zero.
  331.     */
  332.    float x_white;
  333.    float y_white;
  334.    float x_red;
  335.    float y_red;
  336.    float x_green;
  337.    float y_green;
  338.    float x_blue;
  339.    float y_blue;
  340. #endif /* PNG_READ_cHRM_SUPPORTED || PNG_WRITE_cHRM_SUPPORTED */
  341. #if defined(PNG_READ_pCAL_SUPPORTED) || defined(PNG_WRITE_pCAL_SUPPORTED)
  342.    /* The pCAL chunk describes a transformation between the stored pixel
  343.     * values and original physcical data values used to create the image.
  344.     * The integer range [0, 2^bit_depth - 1] maps to the floating-point
  345.     * range given by [pcal_X0, pcal_X1], and are further transformed by a
  346.     * (possibly non-linear) transformation function given by "pcal_type"
  347.     * and "pcal_params" into "pcal_units".  Please see the PNG_EQUATION_
  348.     * defines below, and the PNG-Group's Scientific Visualization extension
  349.     * chunks document png-scivis-19970203 for a complete description of the
  350.     * transformations and how they should be implemented, as well as the
  351.     * png-extensions document for a description of the ASCII parameter
  352.     * strings.  Data values are valid if (valid & PNG_INFO_pCAL) non-zero.
  353.     */
  354.    png_charp pcal_purpose;  /* pCAL chunk description string */
  355.    png_int_32 pcal_X0;      /* minimum value */
  356.    png_int_32 pcal_X1;      /* maximum value */
  357.    png_charp pcal_units;    /* Latin-1 string giving physical units */
  358.    png_charpp pcal_params;  /* ASCII strings containing parameter values */
  359.    png_byte pcal_type;      /* equation type (see PNG_EQUATION_ below) */
  360.    png_byte pcal_nparams;   /* number of parameters given in pcal_params */
  361. #endif /* PNG_READ_pCAL_SUPPORTED || PNG_WRITE_pCAL_SUPPORTED */
  362. } png_info;
  363. typedef png_info FAR * png_infop;
  364. typedef png_info FAR * FAR * png_infopp;
  365.  
  366. /* These describe the color_type field in png_info. */
  367. /* color type masks */
  368. #define PNG_COLOR_MASK_PALETTE    1
  369. #define PNG_COLOR_MASK_COLOR      2
  370. #define PNG_COLOR_MASK_ALPHA      4
  371.  
  372. /* color types.  Note that not all combinations are legal */
  373. #define PNG_COLOR_TYPE_GRAY 0
  374. #define PNG_COLOR_TYPE_PALETTE  (PNG_COLOR_MASK_COLOR | PNG_COLOR_MASK_PALETTE)
  375. #define PNG_COLOR_TYPE_RGB        (PNG_COLOR_MASK_COLOR)
  376. #define PNG_COLOR_TYPE_RGB_ALPHA  (PNG_COLOR_MASK_COLOR | PNG_COLOR_MASK_ALPHA)
  377. #define PNG_COLOR_TYPE_GRAY_ALPHA (PNG_COLOR_MASK_ALPHA)
  378.  
  379. /* This is for compression type. PNG 1.0 only defines the single type. */
  380. #define PNG_COMPRESSION_TYPE_BASE 0 /* Deflate method 8, 32K window */
  381. #define PNG_COMPRESSION_TYPE_DEFAULT PNG_COMPRESSION_TYPE_BASE
  382.  
  383. /* This is for filter type. PNG 1.0 only defines the single type. */
  384. #define PNG_FILTER_TYPE_BASE      0 /* Single row per-byte filtering */
  385. #define PNG_FILTER_TYPE_DEFAULT   PNG_FILTER_TYPE_BASE
  386.  
  387. /* These are for the interlacing type.  These values should NOT be changed. */
  388. #define PNG_INTERLACE_NONE        0 /* Non-interlaced image */
  389. #define PNG_INTERLACE_ADAM7       1 /* Adam7 interlacing */
  390. #define PNG_INTERLACE_LAST        2 /* Not a valid value */
  391.  
  392. /* These are for the oFFs chunk.  These values should NOT be changed. */
  393. #define PNG_OFFSET_PIXEL          0 /* Offset in pixels */
  394. #define PNG_OFFSET_MICROMETER     1 /* Offset in micrometers (1/10^6 meter) */
  395. #define PNG_OFFSET_LAST           2 /* Not a valid value */
  396.  
  397. /* These are for the pCAL chunk.  These values should NOT be changed. */
  398. #define PNG_EQUATION_LINEAR       0 /* Linear transformation */
  399. #define PNG_EQUATION_BASE_E       1 /* Exponential base e transform */
  400. #define PNG_EQUATION_ARBITRARY    2 /* Arbitrary base exponential transform */
  401. #define PNG_EQUATION_HYPERBOLIC   3 /* Hyperbolic sine transformation */
  402. #define PNG_EQUATION_LAST         4 /* Not a valid value */
  403.  
  404. /* These are for the pHYs chunk.  These values should NOT be changed. */
  405. #define PNG_RESOLUTION_UNKNOWN    0 /* pixels/unknown unit (aspect ratio) */
  406. #define PNG_RESOLUTION_METER      1 /* pixels/meter */
  407. #define PNG_RESOLUTION_LAST       2 /* Not a valid value */
  408.  
  409. /* These determine if an ancillary chunk's data has been successfully read
  410.  * from the PNG header, or if the application has filled in the corresponding
  411.  * data in the info_struct to be written into the output file.  The values
  412.  * of the PNG_INFO_<chunk> defines should NOT be changed.
  413.  */
  414. #define PNG_INFO_gAMA 0x0001
  415. #define PNG_INFO_sBIT 0x0002
  416. #define PNG_INFO_cHRM 0x0004
  417. #define PNG_INFO_PLTE 0x0008
  418. #define PNG_INFO_tRNS 0x0010
  419. #define PNG_INFO_bKGD 0x0020
  420. #define PNG_INFO_hIST 0x0040
  421. #define PNG_INFO_pHYs 0x0080
  422. #define PNG_INFO_oFFs 0x0100
  423. #define PNG_INFO_tIME 0x0200
  424. #define PNG_INFO_pCAL 0x0400
  425.  
  426. /* This is used for the transformation routines, as some of them
  427.  * change these values for the row.  It also should enable using
  428.  * the routines for other purposes.
  429.  */
  430. typedef struct png_row_info_struct
  431. {
  432.    png_uint_32 width; /* width of row */
  433.    png_size_t rowbytes; /* number of bytes in row */
  434.    png_byte color_type; /* color type of row */
  435.    png_byte bit_depth; /* bit depth of row */
  436.    png_byte channels; /* number of channels (1, 2, 3, or 4) */
  437.    png_byte pixel_depth; /* bits per pixel (depth * channels) */
  438. } png_row_info;
  439.  
  440. typedef png_row_info FAR * png_row_infop;
  441. typedef png_row_info FAR * FAR * png_row_infopp;
  442.  
  443. /* These are the function types for the I/O functions, and the functions which
  444.  * modify the default I/O functions to user I/O functions.  The png_error_ptr
  445.  * type should match that of user supplied warning and error functions, while
  446.  * the png_rw_ptr type should match that of the user read/write data functions.
  447.  */
  448. typedef struct png_struct_def png_struct;
  449. typedef png_struct FAR * png_structp;
  450.  
  451. typedef void (*png_error_ptr) PNGARG((png_structp, png_const_charp));
  452. typedef void (*png_rw_ptr) PNGARG((png_structp, png_bytep, png_size_t));
  453. typedef void (*png_flush_ptr) PNGARG((png_structp));
  454. #ifdef PNG_PROGRESSIVE_READ_SUPPORTED
  455. typedef void (*png_progressive_info_ptr) PNGARG((png_structp, png_infop));
  456. typedef void (*png_progressive_end_ptr) PNGARG((png_structp, png_infop));
  457. typedef void (*png_progressive_row_ptr) PNGARG((png_structp, png_bytep,
  458.    png_uint_32, int));
  459. #endif /* PNG_PROGRESSIVE_READ_SUPPORTED */
  460.  
  461. /* The structure that holds the information to read and write PNG files.
  462.  * The only people who need to care about what is inside of this are the
  463.  * people who will be modifying the library for their own special needs.
  464.  * It should NOT be accessed directly by an application, except to store
  465.  * the jmp_buf.
  466.  */
  467.  
  468. struct png_struct_def
  469. {
  470.    jmp_buf jmpbuf;            /* used in png_error */
  471.  
  472.    png_error_ptr error_fn;    /* function for printing errors and aborting */
  473.    png_error_ptr warning_fn;  /* function for printing warnings */
  474.    png_voidp error_ptr;       /* user supplied struct for error functions */
  475.    png_rw_ptr write_data_fn;  /* function for writing output data */
  476.    png_rw_ptr read_data_fn;   /* function for reading input data */
  477.    png_voidp io_ptr;          /* ptr to application struct for I/O functions*/
  478.  
  479.    png_uint_32 mode;          /* tells us whre we are in the PNG file */
  480.    png_uint_32 flags;         /* flags indicating various things to libpng */
  481.    png_uint_32 transformations; /* which transformations to perform */
  482.  
  483.    z_stream zstream;          /* pointer to decompression structure (below) */
  484.    png_bytep zbuf;            /* buffer for zlib */
  485.    png_size_t zbuf_size;      /* size of zbuf */
  486.    int zlib_level;            /* holds zlib compression level */
  487.    int zlib_method;           /* holds zlib compression method */
  488.    int zlib_window_bits;      /* holds zlib compression window bits */
  489.    int zlib_mem_level;        /* holds zlib compression memory level */
  490.    int zlib_strategy;         /* holds zlib compression strategy */
  491.  
  492.    png_uint_32 width;         /* width of image in pixels */
  493.    png_uint_32 height;        /* height of image in pixels */
  494.    png_uint_32 num_rows;      /* number of rows in current pass */
  495.    png_uint_32 usr_width;     /* width of row at start of write */
  496.    png_size_t rowbytes;       /* size of row in bytes */
  497.    png_size_t irowbytes;      /* size of current interlaced row in bytes */
  498.    png_uint_32 iwidth;        /* width of current interlaced row in pixels */
  499.    png_uint_32 row_number;    /* current row in interlace pass */
  500.    png_bytep prev_row;        /* buffer to save previous (unfiltered) row */
  501.    png_bytep row_buf;         /* buffer to save current (unfiltered) row */
  502.    png_bytep sub_row;         /* buffer to save "sub" row when filtering */
  503.    png_bytep up_row;          /* buffer to save "up" row when filtering */
  504.    png_bytep avg_row;         /* buffer to save "avg" row when filtering */
  505.    png_bytep paeth_row;       /* buffer to save "Paeth" row when filtering */
  506.    png_row_info row_info;     /* used for transformation routines */
  507.  
  508.    png_uint_32 idat_size;     /* current IDAT size for read */
  509.    png_uint_32 crc;           /* current chunk CRC value */
  510.    png_colorp palette;        /* palette from the input file */
  511.    png_uint_16 num_palette;   /* number of color entries in palette */
  512.    png_uint_16 num_trans;     /* number of transparency values */
  513.    png_byte chunk_name[5];    /* null-terminated name of current chunk */
  514.    png_byte compression;      /* file compression type (always 0) */
  515.    png_byte filter;           /* file filter type (always 0) */
  516.    png_byte interlaced;       /* PNG_INTERLACE_NONE, PNG_INTERLACE_ADAM7 */
  517.    png_byte pass;             /* current interlace pass (0 - 6) */
  518.    png_byte do_filter;        /* row filter flags (see PNG_FILTER_ below ) */
  519.    png_byte color_type;       /* color type of file */
  520.    png_byte bit_depth;        /* bit depth of file */
  521.    png_byte usr_bit_depth;    /* bit depth of users row */
  522.    png_byte pixel_depth;      /* number of bits per pixel */
  523.    png_byte channels;         /* number of channels in file */
  524.    png_byte usr_channels;     /* channels at start of write */
  525.    png_byte sig_bytes;        /* magic bytes read/written from start of file */
  526.  
  527.  
  528. #if defined(PNG_READ_FILLER_SUPPORTED) || defined(PNG_WRITE_FILLER_SUPPORTED)
  529.    png_byte filler;           /* filler byte for 24->32-bit pixel expansion */
  530. #endif /* PNG_READ_FILLER_SUPPORTED */
  531. #if defined(PNG_READ_bKGD_SUPPORTED)
  532.    png_byte background_gamma_type;
  533.    float background_gamma;
  534.    png_color_16 background;   /* background color in screen gamma space */
  535. #if defined(PNG_READ_GAMMA_SUPPORTED)
  536.    png_color_16 background_1; /* background normalized to gamma 1.0 */
  537. #endif /* PNG_READ_GAMMA && PNG_READ_bKGD_SUPPORTED */
  538. #endif /* PNG_READ_bKGD_SUPPORTED */
  539. #if defined(PNG_WRITE_FLUSH_SUPPORTED)
  540.    png_flush_ptr output_flush_fn;/* Function for flushing output */
  541.    png_uint_32 flush_dist;    /* how many rows apart to flush, 0 - no flush */
  542.    png_uint_32 flush_rows;    /* number of rows written since last flush */
  543. #endif /* PNG_WRITE_FLUSH_SUPPORTED */
  544. #if defined(PNG_READ_GAMMA_SUPPORTED)
  545.    int gamma_shift;           /* number of "insignificant" bits 16-bit gamma */
  546.    float gamma;               /* file gamma value */
  547.    float display_gamma;       /* display gamma value */
  548. #endif /* PNG_READ_GAMMA_SUPPORTED */
  549. #if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED)
  550.    png_bytep gamma_table;     /* gamma table for 8 bit depth files */
  551.    png_bytep gamma_from_1;    /* converts from 1.0 to screen */
  552.    png_bytep gamma_to_1;      /* converts from file to 1.0 */
  553.    png_uint_16pp gamma_16_table; /* gamma table for 16 bit depth files */
  554.    png_uint_16pp gamma_16_from_1; /* converts from 1.0 to screen */
  555.    png_uint_16pp gamma_16_to_1; /* converts from file to 1.0 */
  556. #endif /* PNG_READ_GAMMA_SUPPORTED || PNG_WRITE_GAMMA_SUPPORTED */
  557. #if defined(PNG_READ_GAMMA_SUPPORTED) || defined (PNG_READ_sBIT_SUPPORTED)
  558.    png_color_8 sig_bit;       /* significant bits in each available channel */
  559. #endif /* PNG_READ_GAMMA_SUPPORTED || PNG_READ_sBIT_SUPPORTED */
  560. #if defined(PNG_READ_SHIFT_SUPPORTED) || defined(PNG_WRITE_SHIFT_SUPPORTED)
  561.    png_color_8 shift;         /* shift for significant bit tranformation */
  562. #endif /* PNG_READ_SHIFT_SUPPORTED || PNG_WRITE_SHIFT_SUPPORTED */
  563. #if defined(PNG_READ_tRNS_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED)
  564.    png_bytep trans;           /* transparency values for paletted files */
  565.    png_color_16 trans_values; /* transparency values for non-paletted files */
  566. #endif /* PNG_READ_tRNS_SUPPORTED || PNG_READ_BACKGROUND_SUPPORTED */
  567. #ifdef PNG_PROGRESSIVE_READ_SUPPORTED
  568.    png_progressive_info_ptr info_fn; /* called after header data fully read */
  569.    png_progressive_row_ptr row_fn;   /* called after each row is decoded */
  570.    png_progressive_end_ptr end_fn;   /* called after image is complete */
  571.    png_bytep save_buffer_ptr;        /* current location in save_buffer */
  572.    png_bytep save_buffer;            /* buffer for previously read data */
  573.    png_bytep current_buffer_ptr;     /* current location in current_buffer */
  574.    png_bytep current_buffer;         /* buffer for recently used data */
  575.    png_uint_32 push_length;          /* size of current input chunk */
  576.    png_uint_32 skip_length;          /* bytes to skip in input data */
  577.    png_size_t save_buffer_size;      /* amount of data now in save_buffer */
  578.    png_size_t save_buffer_max;       /* total size of save_buffer */
  579.    png_size_t buffer_size;           /* total amount of available input data */
  580.    png_size_t current_buffer_size;   /* amount of data now in current_buffer */
  581.    int process_mode;                 /* what push library is currently doing */
  582.    int cur_palette;                  /* current push library palette index */
  583. #if defined(PNG_READ_tEXt_SUPPORTED) || defined(PNG_READ_zTXt_SUPPORTED)
  584.    png_size_t current_text_size;     /* current size of text input data */
  585.    png_size_t current_text_left;     /* how much text left to read in input */
  586.    png_charp current_text;           /* current text chunk buffer */
  587.    png_charp current_text_ptr;       /* current location in current_text */
  588. #endif /* PNG_PROGRESSIVE_READ_SUPPORTED && PNG_READ_tEXt/zTXt_SUPPORTED */
  589. #if defined(__TURBOC__) && !defined(_Windows) && !defined(__FLAT__)
  590. /* for the Borland special 64K segment handler */
  591.    png_bytepp offset_table_ptr;
  592.    png_bytep offset_table;
  593.    png_uint_16 offset_table_number;
  594.    png_uint_16 offset_table_count;
  595.    png_uint_16 offset_table_count_free;
  596. #endif /* PNG_PROGRESSIVE_READ_SUPPORTED&&__TURBOC__&&!_Windows&&!__FLAT__ */
  597. #endif /* PNG_PROGRESSIVE_READ_SUPPORTED */
  598. #if defined(PNG_READ_DITHER_SUPPORTED)
  599.    png_bytep palette_lookup;         /* lookup table for dithering */
  600.    png_bytep dither_index;           /* index translation for palette files */
  601.    png_uint_16p hist;                /* histogram */
  602. #endif /* PNG_READ_DITHER_SUPPORTED */
  603. #if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED)
  604.    png_byte heuristic_method;        /* heuristic for row filter selection */
  605.    png_byte num_prev_filters;        /* number of weights for previous rows */
  606.    png_bytep prev_filters;           /* filter type(s) of previous row(s) */
  607.    png_uint_16p filter_weights;      /* weight(s) for previous line(s) */
  608.    png_uint_16p inv_filter_weights;  /* 1/weight(s) for previous line(s) */
  609.    png_uint_16p filter_costs;        /* relative filter calculation cost */
  610.    png_uint_16p inv_filter_costs;    /* 1/relative filter calculation cost */
  611. #endif /* PNG_WRITE_WEIGHTED_FILTER_SUPPORTED */
  612. };
  613.  
  614. typedef png_struct FAR * FAR * png_structpp;
  615.  
  616. /* Here are the function definitions most commonly used.  This is not
  617.  * the place to find out how to use libpng.  See libpng.txt for the
  618.  * full explanation, see example.c for the summary.  This just provides
  619.  * a simple one line of the use of each function.
  620.  */
  621.  
  622. /* Tell lib we have already handled the first <num_bytes> magic bytes.
  623.  * Handling more than 8 bytes from the beginning of the file is an error.
  624.  */
  625. extern PNG_EXPORT(void,png_set_sig_bytes) PNGARG((png_structp png_ptr,
  626.    int num_bytes));
  627.  
  628. /* Check sig[start] through sig[start + num_to_check - 1] to see if it's a
  629.  * PNG file.  Returns zero if the supplied bytes match the 8-byte PNG
  630.  * signature, and non-zero otherwise.  Having num_to_check == 0 or
  631.  * start > 7 will always fail (ie return non-zero).
  632.  */
  633. extern PNG_EXPORT(int,png_sig_cmp) PNGARG((png_bytep sig, png_size_t start,
  634.    png_size_t num_to_check));
  635.  
  636. /* Simple signature checking function.  This is the same as calling
  637.  * png_check_sig(sig, n) := !png_sig_cmp(sig, 0, n).
  638.  */
  639. extern PNG_EXPORT(int,png_check_sig) PNGARG((png_bytep sig, int num));
  640.  
  641. /* Allocate and initialize png_ptr struct for reading, and any other memory. */
  642. extern PNG_EXPORT(png_structp,png_create_read_struct)
  643.    PNGARG((png_charp user_png_ver, voidp error_ptr, png_error_ptr error_fn,
  644.    png_error_ptr warn_fn));
  645.  
  646. /* Allocate and initialize png_ptr struct for reading, and any other memory */
  647. extern PNG_EXPORT(png_structp,png_create_write_struct)
  648.    PNGARG((png_const_charp user_png_ver, voidp error_ptr,
  649.    png_error_ptr error_fn, png_error_ptr warn_fn));
  650.  
  651. /* Allocate and initialize the info structure */
  652. extern PNG_EXPORT(png_infop,png_create_info_struct)
  653.    PNGARG((png_structp png_ptr));
  654.  
  655. /* Initialize the info structure (old interface - NOT DLL EXPORTED) */
  656. extern void png_info_init PNGARG((png_infop info_ptr));
  657.  
  658. /* Writes all the PNG information before the image. */
  659. extern PNG_EXPORT(void,png_write_info) PNGARG((png_structp png_ptr,
  660.    png_infop info_ptr));
  661.  
  662. /* read the information before the actual image data. */
  663. extern PNG_EXPORT(void,png_read_info) PNGARG((png_structp png_ptr,
  664.    png_infop info_ptr));
  665.  
  666. #if defined(PNG_WRITE_tIME_SUPPORTED)
  667. /* convert from a struct tm to png_time */
  668. extern PNG_EXPORT(void,png_convert_from_struct_tm) PNGARG((png_timep ptime,
  669.    struct tm FAR * ttime));
  670.  
  671. /* convert from time_t to png_time.  Uses gmtime() */
  672. extern PNG_EXPORT(void,png_convert_from_time_t) PNGARG((png_timep ptime,
  673.    time_t ttime));
  674. #endif /* PNG_WRITE_tIME_SUPPORTED */
  675.  
  676. #if defined(PNG_READ_EXPAND_SUPPORTED)
  677. /* Expand data to 24 bit RGB, or 8 bit grayscale, with alpha if available. */
  678. extern PNG_EXPORT(void,png_set_expand) PNGARG((png_structp png_ptr));
  679. #endif /* PNG_READ_EXPAND_SUPPORTED */
  680.  
  681. #if defined(PNG_READ_BGR_SUPPORTED) || defined(PNG_WRITE_BGR_SUPPORTED)
  682. /* Use blue, green, red order for pixels. */
  683. extern PNG_EXPORT(void,png_set_bgr) PNGARG((png_structp png_ptr));
  684. #endif /* PNG_READ_BGR_SUPPORTED || PNG_WRITE_BGR_SUPPORTED */
  685.  
  686. #if defined(PNG_READ_GRAY_TO_RGB_SUPPORTED)
  687. /* Expand the grayscale to 24 bit RGB if necessary. */
  688. extern PNG_EXPORT(void,png_set_gray_to_rgb) PNGARG((png_structp png_ptr));
  689. #endif /* PNG_READ_GRAY_TO_RGB_SUPPORTED */
  690.  
  691. #if defined(PNG_READ_RGB_TO_GRAY_SUPPORTED)
  692. /* Reduce RGB to grayscale. (Not yet implemented) */
  693. extern PNG_EXPORT(void,png_set_rgb_to_gray) PNGARG((png_structp png_ptr));
  694. #endif /* PNG_READ_RGB_TO_GRAY_SUPPORTED */
  695.  
  696. extern PNG_EXPORT(void,png_build_grayscale_palette) PNGARG((int bit_depth,
  697.    png_colorp palette));
  698.  
  699. #if defined(PNG_READ_STRIP_ALPHA_SUPPORTED)
  700. extern PNG_EXPORT(void,png_set_strip_alpha) PNGARG((png_structp png_ptr));
  701. #endif /* PNG_READ_STRIP_ALPHA_SUPPORTED */
  702.  
  703. #if defined(PNG_READ_SWAP_ALPHA_SUPPORTED) || \
  704.     defined(PNG_WRITE_SWAP_ALPHA_SUPPORTED)
  705. extern PNG_EXPORT(void,png_set_swap_alpha) PNGARG((png_structp png_ptr));
  706. #endif /* PNG_READ_SWAP_ALPHA_SUPPORTED || PNG_WRITE_SWAP_ALPHA_SUPPORTED */
  707.  
  708. #if defined(PNG_READ_FILLER_SUPPORTED) || defined(PNG_WRITE_FILLER_SUPPORTED)
  709. /* Add a filler byte to 24-bit RGB images. */
  710. extern PNG_EXPORT(void,png_set_filler) PNGARG((png_structp png_ptr,
  711.    png_uint_32 filler, int flags));
  712.  
  713. /* The values of the PNG_FILLER_ defines should NOT be changed */
  714. #define PNG_FILLER_BEFORE 0
  715. #define PNG_FILLER_AFTER 1
  716. #endif /* PNG_READ_FILLER_SUPPORTED || PNG_WRITE_FILLER_SUPPORTED */
  717.  
  718. #if defined(PNG_READ_SWAP_SUPPORTED) || defined(PNG_WRITE_SWAP_SUPPORTED)
  719. /* Swap bytes in 16 bit depth files. */
  720. extern PNG_EXPORT(void,png_set_swap) PNGARG((png_structp png_ptr));
  721. #endif /* PNG_READ_SWAP_SUPPORTED || PNG_WRITE_SWAP_SUPPORTED */
  722.  
  723. #if defined(PNG_READ_PACK_SUPPORTED) || defined(PNG_WRITE_PACK_SUPPORTED)
  724. /* Use 1 byte per pixel in 1, 2, or 4 bit depth files. */
  725. extern PNG_EXPORT(void,png_set_packing) PNGARG((png_structp png_ptr));
  726. #endif /* PNG_READ_PACK_SUPPORTED || PNG_WRITE_PACK_SUPPORTED */
  727.  
  728. #if defined(PNG_READ_PACKSWAP_SUPPORTED) || defined(PNG_WRITE_PACKSWAP_SUPPOR)
  729. /* Swap packing order of pixels in bytes. */
  730. extern PNG_EXPORT(void,png_set_packswap) PNGARG((png_structp png_ptr));
  731. #endif /* PNG_READ_PACKSWAP_SUPPORTED || PNG_WRITE_PACKSWAP_SUPPOR */
  732.  
  733. #if defined(PNG_READ_SHIFT_SUPPORTED) || defined(PNG_WRITE_SHIFT_SUPPORTED)
  734. /* Converts files to legal bit depths. */
  735. extern PNG_EXPORT(void,png_set_shift) PNGARG((png_structp png_ptr,
  736.    png_color_8p true_bits));
  737. #endif /* PNG_READ_SHIFT_SUPPORTED || PNG_WRITE_SHIFT_SUPPORTED */
  738.  
  739. #if defined(PNG_READ_INTERLACING_SUPPORTED) || \
  740.     defined(PNG_WRITE_INTERLACING_SUPPORTED)
  741. /* Have the code handle the interlacing.  Returns the number of passes. */
  742. extern PNG_EXPORT(int,png_set_interlace_handling) PNGARG((png_structp png_ptr));
  743. #endif /* PNG_READ_INTERLACING_SUPPORTED || PNG_WRITE_INTERLACING_SUPPORTED */
  744.  
  745. #if defined(PNG_READ_INVERT_SUPPORTED) || defined(PNG_WRITE_INVERT_SUPPORTED)
  746. /* Invert monocrome files */
  747. extern PNG_EXPORT(void,png_set_invert_mono) PNGARG((png_structp png_ptr));
  748. #endif /* PNG_READ_INVERT_SUPPORTED || PNG_WRITE_INVERT_SUPPORTED */
  749.  
  750. #if defined(PNG_READ_BACKGROUND_SUPPORTED)
  751. /* Handle alpha and tRNS by replacing with a background color. */
  752. extern PNG_EXPORT(void,png_set_background) PNGARG((png_structp png_ptr,
  753.    png_color_16p background_color, int background_gamma_code,
  754.    int need_expand, double background_gamma));
  755. #define PNG_BACKGROUND_GAMMA_UNKNOWN 0
  756. #define PNG_BACKGROUND_GAMMA_SCREEN  1
  757. #define PNG_BACKGROUND_GAMMA_FILE    2
  758. #define PNG_BACKGROUND_GAMMA_UNIQUE  3
  759. #endif /* PNG_READ_BACKGROUND_SUPPORTED */
  760.  
  761. #if defined(PNG_READ_16_TO_8_SUPPORTED)
  762. /* strip the second byte of information from a 16 bit depth file. */
  763. extern PNG_EXPORT(void,png_set_strip_16) PNGARG((png_structp png_ptr));
  764. #endif /* PNG_READ_16_TO_8_SUPPORTED */
  765.  
  766. #if defined(PNG_READ_DITHER_SUPPORTED)
  767. /* Turn on dithering, and reduce the palette to the number of colors available. */
  768. extern PNG_EXPORT(void,png_set_dither) PNGARG((png_structp png_ptr,
  769.    png_colorp palette, int num_palette, int maximum_colors,
  770.    png_uint_16p histogram, int full_dither));
  771. #endif /* PNG_READ_DITHER_SUPPORTED */
  772.  
  773. #if defined(PNG_READ_GAMMA_SUPPORTED)
  774. /* Handle gamma correction. */
  775. extern PNG_EXPORT(void,png_set_gamma) PNGARG((png_structp png_ptr,
  776.    double screen_gamma, double default_file_gamma));
  777. #endif /* PNG_READ_GAMMA_SUPPORTED */
  778.  
  779. #if defined(PNG_WRITE_FLUSH_SUPPORTED)
  780. /* Set how many lines between output flushes - 0 for no flushing */
  781. extern PNG_EXPORT(void,png_set_flush) PNGARG((png_structp png_ptr, int nrows));
  782.  
  783. /* Flush the current PNG output buffer */
  784. extern PNG_EXPORT(void,png_write_flush) PNGARG((png_structp png_ptr));
  785. #endif /* PNG_WRITE_FLUSH_SUPPORTED */
  786.  
  787. /* optional update palette with requested transformations */
  788. extern PNG_EXPORT(void,png_start_read_image) PNGARG((png_structp png_ptr));
  789.  
  790. /* optional call to update the users info structure */
  791. extern PNG_EXPORT(void,png_read_update_info) PNGARG((png_structp png_ptr,
  792.    png_infop info_ptr));
  793.  
  794. /* read a one or more rows of image data.*/
  795. extern PNG_EXPORT(void,png_read_rows) PNGARG((png_structp png_ptr,
  796.    png_bytepp row, png_bytepp display_row, png_uint_32 num_rows));
  797.  
  798. /* read a row of data.*/
  799. extern PNG_EXPORT(void,png_read_row) PNGARG((png_structp png_ptr,
  800.    png_bytep row,
  801.    png_bytep display_row));
  802.  
  803. /* read the whole image into memory at once. */
  804. extern PNG_EXPORT(void,png_read_image) PNGARG((png_structp png_ptr,
  805.    png_bytepp image));
  806.  
  807. /* write a row of image data */
  808. extern PNG_EXPORT(void,png_write_row) PNGARG((png_structp png_ptr,
  809.    png_bytep row));
  810.  
  811. /* write a few rows of image data */
  812. extern PNG_EXPORT(void,png_write_rows) PNGARG((png_structp png_ptr,
  813.    png_bytepp row, png_uint_32 num_rows));
  814.  
  815. /* write the image data */
  816. extern PNG_EXPORT(void,png_write_image) PNGARG((png_structp png_ptr,
  817.    png_bytepp image));
  818.  
  819. /* writes the end of the PNG file. */
  820. extern PNG_EXPORT(void,png_write_end) PNGARG((png_structp png_ptr,
  821.    png_infop info_ptr));
  822.  
  823. /* read the end of the PNG file. */
  824. extern PNG_EXPORT(void,png_read_end) PNGARG((png_structp png_ptr,
  825.    png_infop info_ptr));
  826.  
  827. /* free any memory associated with the png_info_struct */
  828. extern PNG_EXPORT(void,png_destroy_info_struct) PNGARG((png_structp png_ptr,
  829.    png_infopp info_ptr_ptr));
  830.  
  831. /* free any memory associated with the png_struct and the png_info_structs */
  832. extern PNG_EXPORT(void,png_destroy_read_struct) PNGARG((png_structpp
  833.    png_ptr_ptr, png_infopp info_ptr_ptr, png_infopp end_info_ptr_ptr));
  834.  
  835. /* free all memory used by the read (old method - NOT DLL EXPORTED) */
  836. extern void png_read_destroy PNGARG((png_structp png_ptr, png_infop info_ptr,
  837.    png_infop end_info_ptr));
  838.  
  839. /* free any memory associated with the png_struct and the png_info_structs */
  840. extern PNG_EXPORT(void,png_destroy_write_struct)
  841.    PNGARG((png_structpp png_ptr_ptr, png_infopp info_ptr_ptr));
  842.  
  843. /* free any memory used in png_ptr struct (old method - NOT DLL EXPORTED) */
  844. extern void png_write_destroy PNGARG((png_structp png_ptr));
  845.  
  846. /* set the libpng method of handling chunk CRC errors */
  847. extern PNG_EXPORT(void,png_set_crc_action) PNGARG((png_structp png_ptr,
  848.    int crit_action, int ancil_action));
  849.  
  850. /* Values for png_set_crc_action() to say how to handle CRC errors in
  851.  * ancillary and critical chunks, and whether to use the data contained
  852.  * therein.  Note that it is impossible to "discard" data in a critical
  853.  * chunk.  For versions prior to 0.90, the action was always error/quit,
  854.  * whereas in version 0.90 and later, the action for CRC errors in ancillary
  855.  * chunks is warn/discard.  These values should NOT be changed.
  856.  *
  857.  *      value                       action:critical     action:ancillary
  858.  */
  859. #define PNG_CRC_DEFAULT       0  /* error/quit          warn/discard data */
  860. #define PNG_CRC_ERROR_QUIT    1  /* error/quit          error/quit        */
  861. #define PNG_CRC_WARN_DISCARD  2  /* (INVALID)           warn/discard data */
  862. #define PNG_CRC_WARN_USE      3  /* warn/use data       warn/use data     */
  863. #define PNG_CRC_QUIET_USE     4  /* quiet/use data      quiet/use data    */
  864. #define PNG_CRC_NO_CHANGE     5  /* use current value   use current value */
  865.  
  866. /* These functions give the user control over the scan-line filtering in
  867.  * libpng and the compression methods used by zlib.  These functions are
  868.  * mainly useful for testing, as the defaults should work with most users.
  869.  * Those users who are tight on memory or want faster performance at the
  870.  * expense of compression can modify them.  See the compression library
  871.  * header file (zlib.h) for an explination of the compression functions. */
  872.  
  873. /* set the filtering method(s) used by libpng.  Currently, the only valid
  874.  * value for "method" is 0 */
  875. extern PNG_EXPORT(void,png_set_filter) PNGARG((png_structp png_ptr, int method,
  876.    int filters));
  877.  
  878. /* Flags for png_set_filter() to say which filters to use.  The flags
  879.  * are chosen so that they don't conflict with real filter types
  880.  * below, in case they are supplied instead of the #defined constants.
  881.  * These values should NOT be changed.
  882.  */
  883. #define PNG_NO_FILTERS     0x00
  884. #define PNG_FILTER_NONE    0x08
  885. #define PNG_FILTER_SUB     0x10
  886. #define PNG_FILTER_UP      0x20
  887. #define PNG_FILTER_AVG     0x40
  888. #define PNG_FILTER_PAETH   0x80
  889. #define PNG_ALL_FILTERS (PNG_FILTER_NONE | PNG_FILTER_SUB | PNG_FILTER_UP | \
  890.                          PNG_FILTER_AVG | PNG_FILTER_PAETH)
  891.  
  892. /* Filter values (not flags) - used in pngwrite.c, pngwutil.c for now.
  893.  * These defines should NOT be changed.
  894.  */
  895. #define PNG_FILTER_VALUE_NONE  0
  896. #define PNG_FILTER_VALUE_SUB   1
  897. #define PNG_FILTER_VALUE_UP    2
  898. #define PNG_FILTER_VALUE_AVG   3
  899. #define PNG_FILTER_VALUE_PAETH 4
  900. #define PNG_FILTER_VALUE_LAST  5
  901.  
  902. #if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED) /* EXPERIMENTAL */
  903. /* The "heuristic_method" is given by one of the PNG_FILTER_HEURISTIC_
  904.  * defines, either the default (minimum-sum-of-absolute-differences), or
  905.  * the experimental method (weighted-minimum-sum-of-absolute-differences).
  906.  *
  907.  * Weights are factors >= 1.0, indicating how important it is to keep the
  908.  * filter type consistent between rows.  Larger numbers mean the current
  909.  * filter is that many times as likely to be the same as the "num_weights"
  910.  * previous filters.  This is cumulative for each previous row with a weight.
  911.  * There needs to be "num_weights" values in "filter_weights", or it can be
  912.  * NULL if the weights aren't being specified.  Weights have no influence on
  913.  * the selection of the first row filter.  Well chosen weights can (in theory)
  914.  * improve the compression for a given image.
  915.  *
  916.  * Costs are factors >= 1.0 indicating the relative decoding costs of a
  917.  * filter type.  Higher costs indicate more decoding expense, and are
  918.  * therefore less likely to be selected over a filter with lower computational
  919.  * costs.  There needs to be a value in "filter_costs" for each valid filter
  920.  * type (given by PNG_FILTER_VALUE_LAST), or it can be NULL if you aren't
  921.  * setting the costs.  Costs try to improve the speed of decompression without
  922.  * unduly increasing the compressed image size.
  923.  *
  924.  * A negative weight or cost indicates the default value is to be used, and
  925.  * values in the range [0.0, 1.0) indicate the value is to remain unchanged.
  926.  * The default values for both weights and costs are currently 1.0, but may
  927.  * change if good general weighting/cost heuristics can be found.  If both
  928.  * the weights and costs are set to 1.0, this degenerates the WEIGHTED method
  929.  * to the UNWEIGHTED method, but with added encoding time/computation.
  930.  */
  931. extern PNG_EXPORT(void,png_set_filter_heuristics) PNGARG((png_structp png_ptr,
  932.    int heuristic_method, int num_weights, png_doublep filter_weights,
  933.    png_doublep filter_costs));
  934. #endif /*  PNG_WRITE_WEIGHTED_FILTER_SUPPORTED */
  935.  
  936. /* Heuristic used for row filter selection.  These defines should NOT be
  937.  * changed.
  938.  */
  939. #define PNG_FILTER_HEURISTIC_DEFAULT    0  /* Currently "UNWEIGHTED" */
  940. #define PNG_FILTER_HEURISTIC_UNWEIGHTED 1  /* Used by libpng < 0.95 */
  941. #define PNG_FILTER_HEURISTIC_WEIGHTED   2  /* Experimental feature */
  942. #define PNG_FILTER_HEURISTIC_LAST       3  /* Not a valid value */
  943.  
  944. /* Set the library compression level.  Currently, valid values range from
  945.  * 0 - 9, corresponding directly to the zlib compression levels 0 - 9
  946.  * (0 - no compression, 9 - "maximal" compression).  Note that tests have
  947.  * shown that zlib compression levels 3-6 usually perform as well as level 9
  948.  * for PNG images, and do considerably fewer caclulations.  In the future,
  949.  * these values may not correspond directly to the zlib compression levels.
  950.  */
  951. extern PNG_EXPORT(void,png_set_compression_level) PNGARG((png_structp png_ptr,
  952.    int level));
  953.  
  954. extern PNG_EXPORT(void,png_set_compression_mem_level)
  955.    PNGARG((png_structp png_ptr, int mem_level));
  956.  
  957. extern PNG_EXPORT(void,png_set_compression_strategy)
  958.    PNGARG((png_structp png_ptr, int strategy));
  959.  
  960. extern PNG_EXPORT(void,png_set_compression_window_bits)
  961.    PNGARG((png_structp png_ptr, int window_bits));
  962.  
  963. extern PNG_EXPORT(void,png_set_compression_method) PNGARG((png_structp png_ptr,
  964.    int method));
  965.  
  966. /* These next functions are called for input/output, memory, and error
  967.  * handling.  They are in the file pngrio.c, pngwio.c, and pngerror.c,
  968.  * and call standard C I/O routines such as fread(), fwrite(), and
  969.  * fprintf().  These functions can be made to use other I/O routines
  970.  * at run time for those applications that need to handle I/O in a
  971.  * different manner by calling png_set_???_fn().  See libpng.txt for
  972.  * more information.
  973.  */
  974.  
  975. /* Initialize the input/output for the PNG file to the default functions. */
  976. extern PNG_EXPORT(void,png_init_io) PNGARG((png_structp png_ptr, FILE *fp));
  977.  
  978. /* Replace the (error and abort), and warning functions with user
  979.  * supplied functions.  If no messages are to be printed you must still
  980.  * write and use replacement functions. The replacement error_fn should
  981.  * still do a longjmp to the last setjmp location if you are using this
  982.  * method of error handling.  If error_fn or warning_fn is NULL, the
  983.  * default function will be used.
  984.  */
  985. extern PNG_EXPORT(void,png_set_error_fn) PNGARG((png_structp png_ptr,
  986.    png_voidp error_ptr, png_error_ptr error_fn, png_error_ptr warning_fn));
  987.  
  988. /* Return the user pointer associated with the error functions */
  989. extern PNG_EXPORT(png_voidp,png_get_error_ptr) PNGARG((png_structp png_ptr));
  990.  
  991. /* Replace the default data output functions with a user supplied one(s).
  992.  * If buffered output is not used, then output_flush_fn can be set to NULL.
  993.  * If PNG_WRITE_FLUSH_SUPPORTED is not defined at libpng compile time
  994.  * output_flush_fn will be ignored (and thus can be NULL).
  995.  */
  996. extern PNG_EXPORT(void,png_set_write_fn) PNGARG((png_structp png_ptr,
  997.    png_voidp io_ptr, png_rw_ptr write_data_fn, png_flush_ptr output_flush_fn));
  998.  
  999. /* Replace the default data input function with a user supplied one. */
  1000. extern PNG_EXPORT(void,png_set_read_fn) PNGARG((png_structp png_ptr,
  1001.    png_voidp io_ptr, png_rw_ptr read_data_fn));
  1002.  
  1003. /* Return the user pointer associated with the I/O functions */
  1004. extern PNG_EXPORT(png_voidp,png_get_io_ptr) PNGARG((png_structp png_ptr));
  1005.  
  1006. #ifdef PNG_PROGRESSIVE_READ_SUPPORTED
  1007. /* Sets the function callbacks for the push reader, and a pointer to a
  1008.  * user-defined structure available to the callback functions.
  1009.  */
  1010. extern PNG_EXPORT(void,png_set_progressive_read_fn) PNGARG((png_structp png_ptr,
  1011.    png_voidp progressive_ptr,
  1012.    png_progressive_info_ptr info_fn, png_progressive_row_ptr row_fn,
  1013.    png_progressive_end_ptr end_fn));
  1014.  
  1015. /* returns the user pointer associated with the push read functions */
  1016. extern PNG_EXPORT(png_voidp,png_get_progressive_ptr)
  1017.    PNGARG((png_structp png_ptr));
  1018.  
  1019. /* function to be called when data becomes available */
  1020. extern PNG_EXPORT(void,png_process_data) PNGARG((png_structp png_ptr,
  1021.    png_infop info_ptr, png_bytep buffer, png_size_t buffer_size));
  1022.  
  1023. /* function which combines rows.  Not very much different than the
  1024.  * png_combine_row() call.  Is this even used?????
  1025.  */
  1026. extern PNG_EXPORT(void,png_progressive_combine_row) PNGARG((png_structp png_ptr,
  1027.    png_bytep old_row, png_bytep new_row));
  1028. #endif /* PNG_PROGRESSIVE_READ_SUPPORTED */
  1029.  
  1030. extern PNG_EXPORT(png_voidp,png_malloc) PNGARG((png_structp png_ptr,
  1031.    png_uint_32 size));
  1032.  
  1033. /* free's a pointer allocated by png_malloc() */
  1034. extern PNG_EXPORT(void,png_free) PNGARG((png_structp png_ptr, png_voidp ptr));
  1035.  
  1036. #if defined(USE_FAR_KEYWORD)  /* memory model conversion function */
  1037. extern void *far_to_near PNGARG((png_structp png_ptr,png_voidp ptr,int check));
  1038. #endif /* USE_FAR_KEYWORD */
  1039.  
  1040. /* Fatal error in PNG image of libpng - can't continue */
  1041. extern PNG_EXPORT(void,png_error) PNGARG((png_structp png_ptr,
  1042.    png_const_charp error));
  1043.  
  1044. /* Non-fatal error in libpng.  Can continue, but may have a problem. */
  1045. extern PNG_EXPORT(void,png_warning) PNGARG((png_structp png_ptr,
  1046.    png_const_charp message));
  1047.  
  1048. /* The png_set_<chunk> functions are for storing values in the png_info_struct.
  1049.  * Similarly, the png_get_<chunk> calls are used to read values from the
  1050.  * png_info_struct, either storing the parameters in the passed variables, or
  1051.  * setting pointers into the png_info_struct where the data is stored.  The
  1052.  * png_get_<chunk> functions return a non-zero value if the data was available
  1053.  * in info_ptr, or return zero and do not change any of the parameters if the
  1054.  * data was not available.
  1055.  *
  1056.  * These functions should be used instead of directly accessing png_info
  1057.  * to avoid problems with future changes in the size and internal layout of
  1058.  * png_info_struct.
  1059.  */
  1060. /* Returns "flag" if chunk data is valid in info_ptr */
  1061. extern PNG_EXPORT(png_uint_32,png_get_valid) PNGARG((png_structp png_ptr,
  1062. png_infop info_ptr, png_uint_32 flag));
  1063.  
  1064. /* Returns number of bytes needed to hold a transformed row */
  1065. extern PNG_EXPORT(png_uint_32,png_get_rowbytes) PNGARG((png_structp png_ptr,
  1066. png_infop info_ptr));
  1067.  
  1068. /* Returns number of color channels in image */
  1069. extern PNG_EXPORT(png_byte,png_get_channels) PNGARG((png_structp png_ptr,
  1070. png_infop info_ptr));
  1071.  
  1072. /* Returns pointer to signature string read from PNG header */
  1073. extern PNG_EXPORT(png_bytep,png_get_signature) PNGARG((png_structp png_ptr,
  1074. png_infop info_ptr));
  1075.  
  1076. #if defined(PNG_READ_bKGD_SUPPORTED)
  1077. extern PNG_EXPORT(png_uint_32,png_get_bKGD) PNGARG((png_structp png_ptr,
  1078.    png_infop info_ptr, png_color_16p *background));
  1079. #endif /* PNG_READ_bKGD_SUPPORTED */
  1080.  
  1081. #if defined(PNG_READ_bKGD_SUPPORTED) || defined(PNG_WRITE_bKGD_SUPPORTED)
  1082. extern PNG_EXPORT(void,png_set_bKGD) PNGARG((png_structp png_ptr,
  1083.    png_infop info_ptr, png_color_16p background));
  1084. #endif /* PNG_READ_bKGD_SUPPORTED || PNG_WRITE_bKGD_SUPPORTED */
  1085.  
  1086. #if defined(PNG_READ_cHRM_SUPPORTED)
  1087. extern PNG_EXPORT(png_uint_32,png_get_cHRM) PNGARG((png_structp png_ptr,
  1088.    png_infop info_ptr, double *white_x, double *white_y, double *red_x,
  1089.    double *red_y, double *green_x, double *green_y, double *blue_x,
  1090.    double *blue_y));
  1091. #endif /* PNG_READ_cHRM_SUPPORTED */
  1092.  
  1093. #if defined(PNG_READ_cHRM_SUPPORTED) || defined(PNG_WRITE_cHRM_SUPPORTED)
  1094. extern PNG_EXPORT(void,png_set_cHRM) PNGARG((png_structp png_ptr,
  1095.    png_infop info_ptr, double white_x, double white_y, double red_x,
  1096.    double red_y, double green_x, double green_y, double blue_x, double blue_y));
  1097. #endif /* PNG_READ_cHRM_SUPPORTED || PNG_WRITE_cHRM_SUPPORTED */
  1098.  
  1099. #if defined(PNG_READ_gAMA_SUPPORTED)
  1100. extern PNG_EXPORT(png_uint_32,png_get_gAMA) PNGARG((png_structp png_ptr,
  1101.    png_infop info_ptr, double *file_gamma));
  1102. #endif /* PNG_READ_gAMA_SUPPORTED */
  1103.  
  1104. #if defined(PNG_READ_gAMA_SUPPORTED) || defined(PNG_WRITE_gAMA_SUPPORTED)
  1105. extern PNG_EXPORT(void,png_set_gAMA) PNGARG((png_structp png_ptr,
  1106.    png_infop info_ptr, double file_gamma));
  1107. #endif /* PNG_READ_gAMA_SUPPORTED || PNG_WRITE_gAMA_SUPPORTED */
  1108.  
  1109. #if defined(PNG_READ_hIST_SUPPORTED)
  1110. extern PNG_EXPORT(png_uint_32,png_get_hIST) PNGARG((png_structp png_ptr,
  1111.    png_infop info_ptr, png_uint_16p *hist));
  1112. #endif /* PNG_READ_hIST_SUPPORTED */
  1113.  
  1114. #if defined(PNG_READ_hIST_SUPPORTED) || defined(PNG_WRITE_hIST_SUPPORTED)
  1115. extern PNG_EXPORT(void,png_set_hIST) PNGARG((png_structp png_ptr,
  1116.    png_infop info_ptr, png_uint_16p hist));
  1117. #endif /* PNG_READ_hIST_SUPPORTED || PNG_WRITE_hIST_SUPPORTED */
  1118.  
  1119. extern PNG_EXPORT(png_uint_32,png_get_IHDR) PNGARG((png_structp png_ptr,
  1120.    png_infop info_ptr, png_uint_32 *width, png_uint_32 *height,
  1121.    int *bit_depth, int *color_type, int *interlace_type,
  1122.    int *compression_type, int *filter_type));
  1123.   
  1124. extern PNG_EXPORT(void,png_set_IHDR) PNGARG((png_structp png_ptr,
  1125.    png_infop info_ptr, png_uint_32 width, png_uint_32 height, int bit_depth,
  1126.    int color_type, int interlace_type, int compression_type, int filter_type));
  1127.  
  1128. #if defined(PNG_READ_oFFs_SUPPORTED)
  1129. extern PNG_EXPORT(png_uint_32,png_get_oFFs) PNGARG((png_structp png_ptr,
  1130.    png_infop info_ptr, png_uint_32 *offset_x, png_uint_32 *offset_y,
  1131.    int *unit_type));
  1132. #endif /* PNG_READ_oFFs_SUPPORTED */
  1133.  
  1134. #if defined(PNG_READ_oFFs_SUPPORTED) || defined(PNG_WRITE_oFFs_SUPPORTED)
  1135. extern PNG_EXPORT(void,png_set_oFFs) PNGARG((png_structp png_ptr,
  1136.    png_infop info_ptr, png_uint_32 offset_x, png_uint_32 offset_y,
  1137.    int unit_type));
  1138. #endif /* PNG_READ_oFFs_SUPPORTED || PNG_WRITE_oFFs_SUPPORTED */
  1139.  
  1140. #if defined(PNG_READ_pCAL_SUPPORTED)
  1141. extern PNG_EXPORT(png_uint_32,png_get_pCAL) PNGARG((png_structp png_ptr,
  1142.    png_infop info_ptr, png_charp *purpose, png_int_32 *X0, png_int_32 *X1,
  1143.    int *type, int *nparams, png_charp *units, png_charpp *params));
  1144. #endif /* PNG_READ_pCAL_SUPPORTED */
  1145.  
  1146. #if defined(PNG_READ_pCAL_SUPPORTED) || defined(PNG_WRITE_pCAL_SUPPORTED)
  1147. extern PNG_EXPORT(void,png_set_pCAL) PNGARG((png_structp png_ptr,
  1148.    png_infop info_ptr, png_charp purpose, png_int_32 X0, png_int_32 X1,
  1149.    int type, int nparams, png_charp units, png_charpp params));
  1150. #endif /* PNG_READ_pCAL_SUPPORTED || PNG_WRITE_pCAL_SUPPORTED */
  1151.  
  1152. #if defined(PNG_READ_pHYs_SUPPORTED)
  1153. extern PNG_EXPORT(png_uint_32,png_get_pHYs) PNGARG((png_structp png_ptr,
  1154.    png_infop info_ptr, png_uint_32 *res_x, png_uint_32 *res_y, int *unit_type));
  1155. #endif /* PNG_READ_pHYs_SUPPORTED */
  1156.  
  1157. #if defined(PNG_READ_pHYs_SUPPORTED) || defined(PNG_WRITE_pHYs_SUPPORTED)
  1158. extern PNG_EXPORT(void,png_set_pHYs) PNGARG((png_structp png_ptr,
  1159.    png_infop info_ptr, png_uint_32 res_x, png_uint_32 res_y, int unit_type));
  1160. #endif /* PNG_READ_pHYs_SUPPORTED || PNG_WRITE_pHYs_SUPPORTED */
  1161.  
  1162. extern PNG_EXPORT(png_uint_32,png_get_PLTE) PNGARG((png_structp png_ptr,
  1163.    png_infop info_ptr, png_colorp *palette, int *num_palette));
  1164.  
  1165. extern PNG_EXPORT(void,png_set_PLTE) PNGARG((png_structp png_ptr,
  1166.    png_infop info_ptr, png_colorp palette, int num_palette));
  1167.  
  1168. #if defined(PNG_READ_sBIT_SUPPORTED)
  1169. extern PNG_EXPORT(png_uint_32,png_get_sBIT) PNGARG((png_structp png_ptr,
  1170.    png_infop info_ptr, png_color_8p *sig_bit));
  1171. #endif /* PNG_READ_sBIT_SUPPORTED */
  1172.  
  1173. #if defined(PNG_READ_sBIT_SUPPORTED) || defined(PNG_WRITE_sBIT_SUPPORTED)
  1174. extern PNG_EXPORT(void,png_set_sBIT) PNGARG((png_structp png_ptr,
  1175.    png_infop info_ptr, png_color_8p sig_bit));
  1176. #endif /* PNG_READ_sBIT_SUPPORTED || PNG_WRITE_sBIT_SUPPORTED */
  1177.  
  1178. #if defined(PNG_READ_tEXt_SUPPORTED) || defined(PNG_READ_zTXt_SUPPORTED)
  1179. /* png_get_text also returns the number of text chunks in text_ptr */
  1180. extern PNG_EXPORT(png_uint_32,png_get_text) PNGARG((png_structp png_ptr,
  1181.    png_infop info_ptr, png_textp *text_ptr, int *num_text));
  1182. #endif /* PNG_READ_tEXt_SUPPORTED || PNG_READ_zTXt_SUPPORTED */
  1183.  
  1184. #if defined(PNG_READ_tEXt_SUPPORTED) || defined(PNG_WRITE_tEXt_SUPPORTED) || \
  1185.     defined(PNG_READ_zTXt_SUPPORTED) || defined(PNG_WRITE_zTXt_SUPPORTED)
  1186. extern PNG_EXPORT(void,png_set_text) PNGARG((png_structp png_ptr,
  1187.    png_infop info_ptr, png_textp text_ptr, int num_text));
  1188. #endif /* PNG_READ_tEXt_SUPPORTED || PNG_WRITE_tEXt_SUPPORTED ||
  1189.           PNG_READ_zTXt_SUPPORTED || PNG_WRITE_zTXt_SUPPORTED */
  1190.  
  1191. #if defined(PNG_READ_tIME_SUPPORTED)
  1192. extern PNG_EXPORT(png_uint_32,png_get_tIME) PNGARG((png_structp png_ptr,
  1193.    png_infop info_ptr, png_timep *mod_time));
  1194. #endif /* PNG_READ_tIME_SUPPORTED */
  1195.  
  1196. #if defined(PNG_READ_tIME_SUPPORTED) || defined(PNG_WRITE_tIME_SUPPORTED)
  1197. extern PNG_EXPORT(void,png_set_tIME) PNGARG((png_structp png_ptr,
  1198.    png_infop info_ptr, png_timep mod_time));
  1199. #endif /* PNG_READ_tIME_SUPPORTED || PNG_WRITE_tIME_SUPPORTED */
  1200.  
  1201. #if defined(PNG_READ_tRNS_SUPPORTED)
  1202. extern PNG_EXPORT(png_uint_32,png_get_tRNS) PNGARG((png_structp png_ptr,
  1203.    png_infop info_ptr, png_bytep *trans, int *num_trans,
  1204.    png_color_16p *trans_values));
  1205. #endif /* PNG_READ_tRNS_SUPPORTED */
  1206.  
  1207. #if defined(PNG_READ_tRNS_SUPPORTED) || defined(PNG_WRITE_tRNS_SUPPORTED)
  1208. extern PNG_EXPORT(void,png_set_tRNS) PNGARG((png_structp png_ptr,
  1209.    png_infop info_ptr, png_bytep trans, int num_trans,
  1210.    png_color_16p trans_values));
  1211. #endif /* PNG_READ_tRNS_SUPPORTED || PNG_WRITE_tRNS_SUPPORTED */
  1212.  
  1213. /* Define PNG_DEBUG at compile time for debugging information.  Higher
  1214.  * numbers for PNG_DEBUG mean more debugging information.  This has
  1215.  * only been added since version 0.95 so it is not implemented throughout
  1216.  * libpng yet, but more support will be added as needed.
  1217.  */
  1218. #if (PNG_DEBUG > 0)
  1219. #ifndef PNG_DEBUG_FILE
  1220. #define PNG_DEBUG_FILE stderr
  1221. #endif /* PNG_DEBUG_FILE */
  1222.  
  1223. #define png_debug(l,m)        if (PNG_DEBUG > l) \
  1224.                                  fprintf(PNG_DEBUG_FILE,"%s"m,(l==1 ? "\t" : \
  1225.                                     (l==2 ? "\t\t":(l==3 ? "\t\t\t":""))))
  1226. #define png_debug1(l,m,p1)    if (PNG_DEBUG > l) \
  1227.                                  fprintf(PNG_DEBUG_FILE,"%s"m,(l==1 ? "\t" : \
  1228.                                     (l==2 ? "\t\t":(l==3 ? "\t\t\t":""))),p1)
  1229. #define png_debug2(l,m,p1,p2) if (PNG_DEBUG > l) \
  1230.                                  fprintf(PNG_DEBUG_FILE,"%s"m,(l==1 ? "\t" : \
  1231.                                     (l==2 ? "\t\t":(l==3 ? "\t\t\t":""))),p1,p2)
  1232. #else
  1233. #define png_debug(l, m)
  1234. #define png_debug1(l, m, p1)
  1235. #define png_debug2(l, m, p1, p2)
  1236. #endif /* (PNG_DEBUG > 0) */
  1237.  
  1238. /* These next functions are used internally in the code.  They generally
  1239.  * shouldn't be used unless you are writing code to add or replace some
  1240.  * functionality in libpng.  More information about most functions can
  1241.  * be found in the files where the functions are located.
  1242.  */
  1243.  
  1244. #if defined(PNG_INTERNAL)
  1245.  
  1246. /* Various modes of operation.  Note that after an init, mode is set to
  1247.    zero automatically when the structure is created. */
  1248. #define PNG_BEFORE_IHDR       0x00
  1249. #define PNG_HAVE_IHDR         0x01
  1250. #define PNG_HAVE_PLTE         0x02
  1251. #define PNG_HAVE_IDAT         0x04
  1252. #define PNG_AFTER_IDAT        0x08
  1253. #define PNG_HAVE_IEND         0x10
  1254.  
  1255. /* push model modes */
  1256. #define PNG_READ_SIG_MODE   0
  1257. #define PNG_READ_CHUNK_MODE 1
  1258. #define PNG_READ_IDAT_MODE  2
  1259. #define PNG_SKIP_MODE       3
  1260. #define PNG_READ_tEXt_MODE  4
  1261. #define PNG_READ_zTXt_MODE  5
  1262. #define PNG_READ_DONE_MODE  6
  1263. #define PNG_ERROR_MODE      7
  1264.  
  1265. /* flags for the transformations the PNG library does on the image data */
  1266. #define PNG_BGR                0x0001
  1267. #define PNG_INTERLACE          0x0002
  1268. #define PNG_PACK               0x0004
  1269. #define PNG_SHIFT              0x0008
  1270. #define PNG_SWAP_BYTES         0x0010
  1271. #define PNG_INVERT_MONO        0x0020
  1272. #define PNG_DITHER             0x0040
  1273. #define PNG_BACKGROUND         0x0080
  1274. #define PNG_BACKGROUND_EXPAND  0x0100
  1275. #define PNG_RGB_TO_GRAY        0x0200 /* Not currently implemented */
  1276. #define PNG_16_TO_8            0x0400
  1277. #define PNG_RGBA               0x0800
  1278. #define PNG_EXPAND             0x1000
  1279. #define PNG_GAMMA              0x2000
  1280. #define PNG_GRAY_TO_RGB        0x4000
  1281. #define PNG_FILLER             0x8000
  1282. #define PNG_PACKSWAP          0x10000
  1283. #define PNG_SWAP_ALPHA        0x20000
  1284. #define PNG_STRIP_ALPHA       0x40000
  1285.  
  1286. /* flags for png_create_struct */
  1287. #define PNG_STRUCT_PNG   0x0001
  1288. #define PNG_STRUCT_INFO  0x0002
  1289.  
  1290. /* Scaling factor for filter heuristic weighting calculations */
  1291. #define PNG_WEIGHT_SHIFT 8
  1292. #define PNG_WEIGHT_FACTOR (1<<(PNG_WEIGHT_SHIFT))
  1293. #define PNG_COST_SHIFT 3
  1294. #define PNG_COST_FACTOR (1<<(PNG_COST_SHIFT))
  1295.  
  1296. /* flags for the png_ptr->flags rather than declaring a byte for each one */
  1297. #define PNG_FLAG_ZLIB_CUSTOM_STRATEGY     0x0001
  1298. #define PNG_FLAG_ZLIB_CUSTOM_LEVEL        0x0002
  1299. #define PNG_FLAG_ZLIB_CUSTOM_MEM_LEVEL    0x0004
  1300. #define PNG_FLAG_ZLIB_CUSTOM_WINDOW_BITS  0x0008
  1301. #define PNG_FLAG_ZLIB_CUSTOM_METHOD       0x0010
  1302. #define PNG_FLAG_ZLIB_FINISHED            0x0020
  1303. #define PNG_FLAG_ROW_INIT                 0x0040
  1304. #define PNG_FLAG_FILLER_AFTER             0x0080
  1305. #define PNG_FLAG_CRC_ANCILLARY_USE        0x0100
  1306. #define PNG_FLAG_CRC_ANCILLARY_NOWARN     0x0200
  1307. #define PNG_FLAG_CRC_CRITICAL_USE         0x0400
  1308. #define PNG_FLAG_CRC_CRITICAL_IGNORE      0x0800
  1309. #define PNG_FLAG_FREE_PALETTE             0x1000
  1310. #define PNG_FLAG_FREE_TRANS               0x2000
  1311. #define PNG_FLAG_FREE_HIST                0x4000
  1312. #define PNG_FLAG_HAVE_CHUNK_HEADER        0x8000
  1313. #define PNG_FLAG_WROTE_tIME              0x10000
  1314.  
  1315. #define PNG_FLAG_CRC_ANCILLARY_MASK (PNG_FLAG_CRC_ANCILLARY_USE | \
  1316.                                      PNG_FLAG_CRC_ANCILLARY_NOWARN)
  1317.  
  1318. #define PNG_FLAG_CRC_CRITICAL_MASK  (PNG_FLAG_CRC_CRITICAL_USE | \
  1319.                                      PNG_FLAG_CRC_CRITICAL_IGNORE)
  1320.  
  1321. #define PNG_FLAG_CRC_MASK           (PNG_FLAG_CRC_ANCILLARY_MASK | \
  1322.                                      PNG_FLAG_CRC_CRITICAL_MASK)
  1323.  
  1324. /* save typing and make code easier to understand */
  1325. #define PNG_COLOR_DIST(c1, c2) (abs((int)((c1).red) - (int)((c2).red)) + \
  1326.    abs((int)((c1).green) - (int)((c2).green)) + \
  1327.    abs((int)((c1).blue) - (int)((c2).blue)))
  1328.  
  1329. /* variables declared in png.c - only it needs to define PNG_NO_EXTERN */
  1330. #ifndef PNG_NO_EXTERN
  1331. /* place to hold the signiture string for a PNG file. */
  1332. extern png_byte FARDATA png_sig[];
  1333.  
  1334. /* constant strings for known chunk types.  If you need to add a chunk,
  1335.    add a string holding the name here.  See png.c for more details.  We
  1336.    can't selectively include these, since we still check for chunk in the
  1337.    wrong locations with these labels. */
  1338. extern png_byte FARDATA png_IHDR[];
  1339. extern png_byte FARDATA png_IDAT[];
  1340. extern png_byte FARDATA png_IEND[];
  1341. extern png_byte FARDATA png_PLTE[];
  1342. extern png_byte FARDATA png_bKGD[];
  1343. extern png_byte FARDATA png_cHRM[];
  1344. extern png_byte FARDATA png_gAMA[];
  1345. extern png_byte FARDATA png_hIST[];
  1346. extern png_byte FARDATA png_oFFs[];
  1347. extern png_byte FARDATA png_pCAL[];
  1348. extern png_byte FARDATA png_pHYs[];
  1349. extern png_byte FARDATA png_sBIT[];
  1350. extern png_byte FARDATA png_tEXt[];
  1351. extern png_byte FARDATA png_tIME[];
  1352. extern png_byte FARDATA png_tRNS[];
  1353. extern png_byte FARDATA png_zTXt[];
  1354.  
  1355. #endif /* PNG_NO_EXTERN */
  1356.  
  1357. /* Inline macros to do direct reads of bytes from the input buffer.  These
  1358.  * require that you are using an architecture that uses PNG byte ordering
  1359.  * (MSB first) and supports unaligned data storage.  I think that PowerPC
  1360.  * in big-endian mode and 680x0 are the only ones that will support this.
  1361.  * The x86 line of processors definitely do not.  The png_get_int_32()
  1362.  * routine also assumes we are using two's complement format for negative
  1363.  * values, which is almost certainly true.
  1364.  */
  1365. #if defined(PNG_READ_BIG_ENDIAN_SUPPORTED)
  1366. #if defined(PNG_READ_pCAL_SUPPORTED)
  1367. #define png_get_int_32(buf) ( *((png_int_32p) (buf)))
  1368. #endif /* PNG_READ_pCAL_SUPPORTED */
  1369. #define png_get_uint_32(buf) ( *((png_uint_32p) (buf)))
  1370. #define png_get_uint_16(buf) ( *((png_uint_16p) (buf)))
  1371. #else
  1372. #if defined(PNG_READ_pCAL_SUPPORTED)
  1373. PNG_EXTERN png_int_32 png_get_int_32 PNGARG((png_bytep buf));
  1374. #endif /* PNG_READ_pCAL_SUPPORTED */
  1375. PNG_EXTERN png_uint_32 png_get_uint_32 PNGARG((png_bytep buf));
  1376. PNG_EXTERN png_uint_16 png_get_uint_16 PNGARG((png_bytep buf));
  1377. #endif /* PNG_BIG_ENDIAN_GET_SUPPORTED */
  1378.  
  1379. /* Initialize png_ptr struct for reading, and allocate any other memory
  1380.  * (old interface - NOT DLL EXPORTED) */
  1381. extern void png_read_init PNGARG((png_structp png_ptr));
  1382.  
  1383. /* Initialize png_ptr struct for writing, and allocate any other memory
  1384.  * (old interface - NOT DLL EXPORTED) */
  1385. extern void png_write_init PNGARG((png_structp png_ptr));
  1386.  
  1387. /* allocate memory for an internal libpng struct */
  1388. PNG_EXTERN png_voidp png_create_struct PNGARG((int type));
  1389.  
  1390. /* free memory from internal libpng struct */
  1391. PNG_EXTERN void png_destroy_struct PNGARG((png_voidp struct_ptr));
  1392.  
  1393. /* free any memory that info_ptr points to and reset struct. */
  1394. PNG_EXTERN void png_info_destroy PNGARG((png_structp png_ptr,
  1395.    png_infop info_ptr));
  1396.  
  1397. /* Function to allocate memory for zlib. */
  1398. PNG_EXTERN voidpf png_zalloc PNGARG((voidpf png_ptr, uInt items, uInt size));
  1399.  
  1400. /* function to free memory for zlib */
  1401. PNG_EXTERN void png_zfree PNGARG((voidpf png_ptr, voidpf ptr));
  1402.  
  1403. /* reset the CRC variable */
  1404. PNG_EXTERN void png_reset_crc PNGARG((png_structp png_ptr));
  1405.  
  1406. /* Write the "data" buffer to whatever output you are using. */
  1407. PNG_EXTERN void png_write_data PNGARG((png_structp png_ptr, png_bytep data,
  1408.    png_size_t length));
  1409.  
  1410. /* Read data from whatever input you are using into the "data" buffer */
  1411. PNG_EXTERN void png_read_data PNGARG((png_structp png_ptr, png_bytep data,
  1412.    png_size_t length));
  1413.  
  1414. /* read bytes into buf, and update png_ptr->crc */
  1415. PNG_EXTERN void png_crc_read PNGARG((png_structp png_ptr, png_bytep buf,
  1416.    png_size_t length));
  1417.  
  1418. /* read "skip" bytes, read the file crc, and (optionally) verify png_ptr->crc */
  1419. PNG_EXTERN int png_crc_finish PNGARG((png_structp png_ptr, png_uint_32 skip));
  1420.  
  1421. /* read the CRC from the file and compare it to the libpng calculated CRC */
  1422. PNG_EXTERN int png_crc_error PNGARG((png_structp png_ptr));
  1423.  
  1424. /* Calculate the CRC over a section of data.  Note that we are only
  1425.  * passing a maximum of 64K on systems that have this as a memory limit,
  1426.  * since this is the maximum buffer size we can specify.
  1427.  */
  1428. PNG_EXTERN void png_calculate_crc PNGARG((png_structp png_ptr, png_bytep ptr,
  1429.    png_size_t length));
  1430.  
  1431. #if defined(PNG_WRITE_FLUSH_SUPPORTED)
  1432. PNG_EXTERN void png_flush PNGARG((png_structp png_ptr));
  1433. #endif
  1434.  
  1435. /* Place a 32-bit number into a buffer in PNG byte order (big-endian).
  1436.  * The only currently known PNG chunk that uses unsigned numbers is
  1437.  * the ancillary extension chunk, pCAL.
  1438.  */
  1439. PNG_EXTERN void png_save_uint_32 PNGARG((png_bytep buf, png_uint_32 i));
  1440.  
  1441. #if defined(PNG_WRITE_pCAL_SUPPORTED)
  1442. PNG_EXTERN void png_save_int_32 PNGARG((png_bytep buf, png_int_32 i));
  1443. #endif
  1444.  
  1445. /* place a 16 bit number into a buffer in PNG byte order */
  1446. PNG_EXTERN void png_save_uint_16 PNGARG((png_bytep buf, png_uint_16 i));
  1447.  
  1448. /* Write a PNG chunk - size, type, (optional) data, CRC. */
  1449. PNG_EXTERN void png_write_chunk PNGARG((png_structp png_ptr,
  1450.    png_bytep chunk_name, png_bytep data, png_size_t length));
  1451.  
  1452. /* Write the start of a PNG chunk - length and chunk name. */
  1453. PNG_EXTERN void png_write_chunk_start PNGARG((png_structp png_ptr,
  1454.    png_bytep chunk_name, png_uint_32 length));
  1455.  
  1456. /* Write the data of a PNG chunk started with png_write_chunk_start(). */
  1457. PNG_EXTERN void png_write_chunk_data PNGARG((png_structp png_ptr,
  1458.    png_bytep data, png_size_t length));
  1459.  
  1460. /* Finish a chunk started with png_write_chunk_start() (includes CRC). */
  1461. PNG_EXTERN void png_write_chunk_end PNGARG((png_structp png_ptr));
  1462.  
  1463. /* simple function to write the signiture */
  1464. PNG_EXTERN void png_write_sig PNGARG((png_structp png_ptr));
  1465.  
  1466. /* write various chunks */
  1467.  
  1468. /* Write the IHDR chunk, and update the png_struct with the necessary
  1469.    information. */
  1470. PNG_EXTERN void png_write_IHDR PNGARG((png_structp png_ptr, png_uint_32 width,
  1471.    png_uint_32 height,
  1472.    int bit_depth, int color_type, int compression_type, int filter_type,
  1473.    int interlace_type));
  1474.  
  1475. PNG_EXTERN void png_write_PLTE PNGARG((png_structp png_ptr, png_colorp palette,
  1476.    png_uint_32 num_pal));
  1477.  
  1478. PNG_EXTERN void png_write_IDAT PNGARG((png_structp png_ptr, png_bytep data,
  1479.    png_size_t length));
  1480.  
  1481. PNG_EXTERN void png_write_IEND PNGARG((png_structp png_ptr));
  1482.  
  1483. #if defined(PNG_WRITE_gAMA_SUPPORTED)
  1484. PNG_EXTERN void png_write_gAMA PNGARG((png_structp png_ptr, double file_gamma));
  1485. #endif
  1486.  
  1487. #if defined(PNG_WRITE_sBIT_SUPPORTED)
  1488. PNG_EXTERN void png_write_sBIT PNGARG((png_structp png_ptr, png_color_8p sbit,
  1489.    int color_type));
  1490. #endif
  1491.  
  1492. #if defined(PNG_WRITE_cHRM_SUPPORTED)
  1493. PNG_EXTERN void png_write_cHRM PNGARG((png_structp png_ptr,
  1494.    double white_x, double white_y,
  1495.    double red_x, double red_y, double green_x, double green_y,
  1496.    double blue_x, double blue_y));
  1497. #endif
  1498.  
  1499. #if defined(PNG_WRITE_tRNS_SUPPORTED)
  1500. PNG_EXTERN void png_write_tRNS PNGARG((png_structp png_ptr, png_bytep trans,
  1501.    png_color_16p values, int number, int color_type));
  1502. #endif
  1503.  
  1504. #if defined(PNG_WRITE_bKGD_SUPPORTED)
  1505. PNG_EXTERN void png_write_bKGD PNGARG((png_structp png_ptr,
  1506.    png_color_16p values, int color_type));
  1507. #endif
  1508.  
  1509. #if defined(PNG_WRITE_hIST_SUPPORTED)
  1510. PNG_EXTERN void png_write_hIST PNGARG((png_structp png_ptr, png_uint_16p hist,
  1511.    png_uint_32 num_hist));
  1512. #endif
  1513.  
  1514. #if defined(PNG_WRITE_tEXt_SUPPORTED) || defined(PNG_WRITE_zTXt_SUPPORTED)
  1515. PNG_EXTERN png_size_t png_check_keyword PNGARG((png_structp png_ptr,
  1516.    png_charp key, png_bytepp new_key));
  1517. #endif
  1518.  
  1519. #if defined(PNG_WRITE_tEXt_SUPPORTED)
  1520. PNG_EXTERN void png_write_tEXt PNGARG((png_structp png_ptr, png_charp key,
  1521.    png_charp text, png_size_t text_len));
  1522. #endif
  1523.  
  1524. #if defined(PNG_WRITE_zTXt_SUPPORTED)
  1525. PNG_EXTERN void png_write_zTXt PNGARG((png_structp png_ptr, png_charp key,
  1526.    png_charp text, png_size_t text_len, int compression));
  1527. #endif
  1528.  
  1529. #if defined(PNG_WRITE_oFFs_SUPPORTED)
  1530. PNG_EXTERN void png_write_oFFs PNGARG((png_structp png_ptr,
  1531.    png_uint_32 x_offset, png_uint_32 y_offset, int unit_type));
  1532. #endif
  1533.  
  1534. #if defined(PNG_WRITE_pCAL_SUPPORTED)
  1535. PNG_EXTERN void png_write_pCAL PNGARG((png_structp png_ptr, png_charp purpose,
  1536.    png_int_32 X0, png_int_32 X1, int type, int nparams,
  1537.    png_charp units, png_charpp params));
  1538. #endif
  1539.  
  1540. #if defined(PNG_WRITE_pHYs_SUPPORTED)
  1541. PNG_EXTERN void png_write_pHYs PNGARG((png_structp png_ptr,
  1542.    png_uint_32 x_pixels_per_unit, png_uint_32 y_pixels_per_unit,
  1543.    int unit_type));
  1544. #endif
  1545.  
  1546. #if defined(PNG_WRITE_tIME_SUPPORTED)
  1547. PNG_EXTERN void png_write_tIME PNGARG((png_structp png_ptr,
  1548.    png_timep mod_time));
  1549. #endif
  1550.  
  1551. /* Called when finished processing a row of data */
  1552. PNG_EXTERN void png_write_finish_row PNGARG((png_structp png_ptr));
  1553.  
  1554. /* Internal use only.   Called before first row of data */
  1555. PNG_EXTERN void png_write_start_row PNGARG((png_structp png_ptr));
  1556.  
  1557. #if defined(PNG_READ_GAMMA_SUPPORTED)
  1558. PNG_EXTERN void png_build_gamma_table PNGARG((png_structp png_ptr));
  1559. #endif
  1560.  
  1561. /* combine a row of data, dealing with alpha, etc. if requested */
  1562. PNG_EXTERN void png_combine_row PNGARG((png_structp png_ptr, png_bytep row,
  1563.    int mask));
  1564.  
  1565. #if defined(PNG_READ_INTERLACING_SUPPORTED)
  1566. /* expand an interlaced row */
  1567. PNG_EXTERN void png_do_read_interlace PNGARG((png_row_infop row_info,
  1568.    png_bytep row, int pass, png_uint_32 transformations));
  1569. #endif
  1570.  
  1571. #if defined(PNG_WRITE_INTERLACING_SUPPORTED)
  1572. /* grab pixels out of a row for an interlaced pass */
  1573. PNG_EXTERN void png_do_write_interlace PNGARG((png_row_infop row_info,
  1574.    png_bytep row, int pass));
  1575. #endif
  1576.  
  1577. /* unfilter a row */
  1578. PNG_EXTERN void png_read_filter_row PNGARG((png_structp png_ptr,
  1579.    png_row_infop row_info, png_bytep row, png_bytep prev_row, int filter));
  1580.  
  1581. /* Choose the best filter to use and filter the row data */
  1582. PNG_EXTERN void png_write_find_filter PNGARG((png_structp png_ptr,
  1583.    png_row_infop row_info));
  1584.  
  1585. /* Write out the filtered row. */
  1586. PNG_EXTERN void png_write_filtered_row PNGARG((png_structp png_ptr,
  1587.    png_bytep filtered_row));
  1588. /* finish a row while reading, dealing with interlacing passes, etc. */
  1589. PNG_EXTERN void png_read_finish_row PNGARG((png_structp png_ptr));
  1590.  
  1591. /* initialize the row buffers, etc. */
  1592. PNG_EXTERN void png_read_start_row PNGARG((png_structp png_ptr));
  1593. /* optional call to update the users info structure */
  1594. PNG_EXTERN void png_read_transform_info PNGARG((png_structp png_ptr,
  1595.    png_infop info_ptr));
  1596.  
  1597. /* these are the functions that do the transformations */
  1598. #if defined(PNG_READ_FILLER_SUPPORTED)
  1599. PNG_EXTERN void png_do_read_filler PNGARG((png_row_infop row_info,
  1600.    png_bytep row, png_uint_32 filler, png_uint_32 flags));
  1601. #endif
  1602.  
  1603. #if defined(PNG_READ_SWAP_ALPHA_SUPPORTED)
  1604. PNG_EXTERN void png_do_read_swap_alpha PNGARG((png_row_infop row_info,
  1605.    png_bytep row));
  1606. #endif
  1607.  
  1608. #if defined(PNG_WRITE_SWAP_ALPHA_SUPPORTED)
  1609. PNG_EXTERN void png_do_write_swap_alpha PNGARG((png_row_infop row_info,
  1610.    png_bytep row));
  1611. #endif
  1612.  
  1613. #if defined(PNG_WRITE_FILLER_SUPPORTED) || \
  1614.     defined(PNG_READ_STRIP_ALPHA_SUPPORTED)
  1615. PNG_EXTERN void png_do_strip_filler PNGARG((png_row_infop row_info,
  1616.    png_bytep row, png_uint_32 flags));
  1617. #endif
  1618.  
  1619. #if defined(PNG_READ_SWAP_SUPPORTED) || defined(PNG_WRITE_SWAP_SUPPORTED)
  1620. PNG_EXTERN void png_do_swap PNGARG((png_row_infop row_info, png_bytep row));
  1621. #endif
  1622.  
  1623. #if defined(PNG_READ_PACKSWAP_SUPPORTED) || defined(PNG_WRITE_PACKSWAP_SUPPOR)
  1624. PNG_EXTERN void png_do_packswap PNGARG((png_row_infop row_info, png_bytep row));
  1625. #endif
  1626.  
  1627. #if defined(PNG_READ_RGB_TO_GRAY_SUPPORTED)
  1628. PNG_EXTERN void png_do_rgb_to_gray PNGARG((png_row_infop row_info,
  1629.    png_bytep row));
  1630. #endif
  1631.  
  1632. #if defined(PNG_READ_GRAY_TO_RGB_SUPPORTED)
  1633. PNG_EXTERN void png_do_gray_to_rgb PNGARG((png_row_infop row_info,
  1634.    png_bytep row));
  1635. #endif
  1636.  
  1637. #if defined(PNG_READ_PACK_SUPPORTED)
  1638. PNG_EXTERN void png_do_unpack PNGARG((png_row_infop row_info, png_bytep row));
  1639. #endif
  1640.  
  1641. #if defined(PNG_READ_SHIFT_SUPPORTED)
  1642. PNG_EXTERN void png_do_unshift PNGARG((png_row_infop row_info, png_bytep row,
  1643.    png_color_8p sig_bits));
  1644. #endif
  1645.  
  1646. #if defined(PNG_READ_INVERT_SUPPORTED) || defined(PNG_WRITE_INVERT_SUPPORTED)
  1647. PNG_EXTERN void png_do_invert PNGARG((png_row_infop row_info, png_bytep row));
  1648. #endif
  1649.  
  1650. #if defined(PNG_READ_16_TO_8_SUPPORTED)
  1651. PNG_EXTERN void png_do_chop PNGARG((png_row_infop row_info, png_bytep row));
  1652. #endif
  1653.  
  1654. #if defined(PNG_READ_DITHER_SUPPORTED)
  1655. PNG_EXTERN void png_do_dither PNGARG((png_row_infop row_info,
  1656.    png_bytep row, png_bytep palette_lookup, png_bytep dither_lookup));
  1657.  
  1658. #  if defined(PNG_CORRECT_PALETTE_SUPPORTED)
  1659. PNG_EXTERN void png_correct_palette PNGARG((png_structp png_ptr,
  1660.    png_colorp palette, int num_palette));
  1661. #  endif
  1662. #endif
  1663.  
  1664. #if defined(PNG_READ_BGR_SUPPORTED) || defined(PNG_WRITE_BGR_SUPPORTED)
  1665. PNG_EXTERN void png_do_bgr PNGARG((png_row_infop row_info, png_bytep row));
  1666. #endif
  1667.  
  1668. #if defined(PNG_WRITE_PACK_SUPPORTED)
  1669. PNG_EXTERN void png_do_pack PNGARG((png_row_infop row_info,
  1670.    png_bytep row, png_uint_32 bit_depth));
  1671. #endif
  1672.  
  1673. #if defined(PNG_WRITE_SHIFT_SUPPORTED)
  1674. PNG_EXTERN void png_do_shift PNGARG((png_row_infop row_info, png_bytep row,
  1675.    png_color_8p bit_depth));
  1676. #endif
  1677.  
  1678. #if defined(PNG_READ_BACKGROUND_SUPPORTED)
  1679. PNG_EXTERN void png_do_background PNGARG((png_row_infop row_info, png_bytep row,
  1680.    png_color_16p trans_values, png_color_16p background,
  1681.    png_color_16p background_1,
  1682.    png_bytep gamma_table, png_bytep gamma_from_1, png_bytep gamma_to_1,
  1683.    png_uint_16pp gamma_16, png_uint_16pp gamma_16_from_1,
  1684.    png_uint_16pp gamma_16_to_1, int gamma_shift));
  1685. #endif
  1686.  
  1687. #if defined(PNG_READ_GAMMA_SUPPORTED)
  1688. PNG_EXTERN void png_do_gamma PNGARG((png_row_infop row_info, png_bytep row,
  1689.    png_bytep gamma_table, png_uint_16pp gamma_16_table,
  1690.    int gamma_shift));
  1691. #endif
  1692.  
  1693. #if defined(PNG_READ_EXPAND_SUPPORTED)
  1694. PNG_EXTERN void png_do_expand_palette PNGARG((png_row_infop row_info,
  1695.    png_bytep row, png_colorp palette, png_bytep trans, int num_trans));
  1696. PNG_EXTERN void png_do_expand PNGARG((png_row_infop row_info,
  1697.    png_bytep row, png_color_16p trans_value));
  1698. #endif
  1699.  
  1700. /* The following decodes the appropriate chunks, and does error correction,
  1701.  * then calls the appropriate callback for the chunk if it is valid */
  1702.  
  1703. /* decode the IHDR chunk */
  1704. PNG_EXTERN void png_handle_IHDR PNGARG((png_structp png_ptr, png_infop info_ptr,
  1705.    png_uint_32 length));
  1706. PNG_EXTERN void png_handle_PLTE PNGARG((png_structp png_ptr, png_infop info_ptr,
  1707.    png_uint_32 length));
  1708. PNG_EXTERN void png_handle_IEND PNGARG((png_structp png_ptr, png_infop info_ptr,
  1709.    png_uint_32 length));
  1710.  
  1711. #if defined(PNG_READ_gAMA_SUPPORTED)
  1712. PNG_EXTERN void png_handle_gAMA PNGARG((png_structp png_ptr, png_infop info_ptr,
  1713.    png_uint_32 length));
  1714. #endif
  1715.  
  1716. #if defined(PNG_READ_sBIT_SUPPORTED)
  1717. PNG_EXTERN void png_handle_sBIT PNGARG((png_structp png_ptr, png_infop info_ptr,
  1718.    png_uint_32 length));
  1719. #endif
  1720.  
  1721. #if defined(PNG_READ_cHRM_SUPPORTED)
  1722. PNG_EXTERN void png_handle_cHRM PNGARG((png_structp png_ptr, png_infop info_ptr,
  1723.    png_uint_32 length));
  1724. #endif
  1725.  
  1726. #if defined(PNG_READ_tRNS_SUPPORTED)
  1727. PNG_EXTERN void png_handle_tRNS PNGARG((png_structp png_ptr, png_infop info_ptr,
  1728.    png_uint_32 length));
  1729. #endif
  1730.  
  1731. #if defined(PNG_READ_bKGD_SUPPORTED)
  1732. PNG_EXTERN void png_handle_bKGD PNGARG((png_structp png_ptr, png_infop info_ptr,
  1733.    png_uint_32 length));
  1734. #endif
  1735.  
  1736. #if defined(PNG_READ_hIST_SUPPORTED)
  1737. PNG_EXTERN void png_handle_hIST PNGARG((png_structp png_ptr, png_infop info_ptr,
  1738.    png_uint_32 length));
  1739. #endif
  1740.  
  1741. #if defined(PNG_READ_oFFs_SUPPORTED)
  1742. PNG_EXTERN void png_handle_oFFs PNGARG((png_structp png_ptr, png_infop info_ptr,
  1743.    png_uint_32 length));
  1744. #endif
  1745.  
  1746. #if defined(PNG_READ_pCAL_SUPPORTED)
  1747. PNG_EXTERN void png_handle_pCAL PNGARG((png_structp png_ptr, png_infop info_ptr,
  1748.    png_uint_32 length));
  1749. #endif
  1750.  
  1751. #if defined(PNG_READ_pHYs_SUPPORTED)
  1752. PNG_EXTERN void png_handle_pHYs PNGARG((png_structp png_ptr, png_infop info_ptr,
  1753.    png_uint_32 length));
  1754. #endif
  1755.  
  1756. #if defined(PNG_READ_tIME_SUPPORTED)
  1757. PNG_EXTERN void png_handle_tIME PNGARG((png_structp png_ptr, png_infop info_ptr,
  1758.    png_uint_32 length));
  1759. #endif
  1760.  
  1761. #if defined(PNG_READ_tEXt_SUPPORTED)
  1762. PNG_EXTERN void png_handle_tEXt PNGARG((png_structp png_ptr, png_infop info_ptr,
  1763.    png_uint_32 length));
  1764. #endif
  1765.  
  1766. #if defined(PNG_READ_zTXt_SUPPORTED)
  1767. PNG_EXTERN void png_handle_zTXt PNGARG((png_structp png_ptr, png_infop info_ptr,
  1768.    png_uint_32 length));
  1769. #endif
  1770.  
  1771. PNG_EXTERN void png_handle_unknown PNGARG((png_structp png_ptr,
  1772.    png_infop info_ptr, png_uint_32 length));
  1773.  
  1774. PNG_EXTERN void png_check_chunk_name PNGARG((png_structp png_ptr,
  1775.    png_bytep chunk_name));
  1776.  
  1777. /* handle the transformations for reading and writing */
  1778. PNG_EXTERN void png_do_read_transformations PNGARG((png_structp png_ptr));
  1779. PNG_EXTERN void png_do_write_transformations PNGARG((png_structp png_ptr));
  1780.  
  1781. PNG_EXTERN void png_init_read_transformations PNGARG((png_structp png_ptr));
  1782.  
  1783. #ifdef PNG_PROGRESSIVE_READ_SUPPORTED
  1784. PNG_EXTERN void png_push_read_chunk PNGARG((png_structp png_ptr,
  1785.    png_infop info_ptr));
  1786. PNG_EXTERN void png_push_read_sig PNGARG((png_structp png_ptr,
  1787.    png_infop info_ptr));
  1788. PNG_EXTERN void png_push_check_crc PNGARG((png_structp png_ptr));
  1789. PNG_EXTERN void png_push_crc_skip PNGARG((png_structp png_ptr,
  1790.    png_uint_32 length));
  1791. PNG_EXTERN void png_push_crc_finish PNGARG((png_structp png_ptr));
  1792. PNG_EXTERN void png_push_fill_buffer PNGARG((png_structp png_ptr,
  1793.    png_bytep buffer, png_size_t length));
  1794. PNG_EXTERN void png_push_save_buffer PNGARG((png_structp png_ptr));
  1795. PNG_EXTERN void png_push_restore_buffer PNGARG((png_structp png_ptr,
  1796.    png_bytep buffer, png_size_t buffer_length));
  1797. PNG_EXTERN void png_push_read_IDAT PNGARG((png_structp png_ptr));
  1798. PNG_EXTERN void png_process_IDAT_data PNGARG((png_structp png_ptr,
  1799.    png_bytep buffer, png_size_t buffer_length));
  1800. PNG_EXTERN void png_push_process_row PNGARG((png_structp png_ptr));
  1801. PNG_EXTERN void png_push_handle_unknown PNGARG((png_structp png_ptr,
  1802.    png_infop info_ptr, png_uint_32 length));
  1803. PNG_EXTERN void png_push_have_info PNGARG((png_structp png_ptr,
  1804.    png_infop info_ptr));
  1805. PNG_EXTERN void png_push_have_end PNGARG((png_structp png_ptr,
  1806.    png_infop info_ptr));
  1807. PNG_EXTERN void png_push_have_row PNGARG((png_structp png_ptr, png_bytep row));
  1808. PNG_EXTERN void png_push_read_end PNGARG((png_structp png_ptr,
  1809.    png_infop info_ptr));
  1810. PNG_EXTERN void png_process_some_data PNGARG((png_structp png_ptr,
  1811.    png_infop info_ptr));
  1812. PNG_EXTERN void png_read_push_finish_row PNGARG((png_structp png_ptr));
  1813. #if defined(PNG_READ_tEXt_SUPPORTED)
  1814. PNG_EXTERN void png_push_handle_tEXt PNGARG((png_structp png_ptr,
  1815.    png_infop info_ptr, png_uint_32 length));
  1816. PNG_EXTERN void png_push_read_tEXt PNGARG((png_structp png_ptr,
  1817.    png_infop info_ptr));
  1818. #endif
  1819. #if defined(PNG_READ_zTXt_SUPPORTED)
  1820. PNG_EXTERN void png_push_handle_zTXt PNGARG((png_structp png_ptr,
  1821.    png_infop info_ptr, png_uint_32 length));
  1822. PNG_EXTERN void png_push_read_zTXt PNGARG((png_structp png_ptr,
  1823.    png_infop info_ptr));
  1824. #endif
  1825.  
  1826. #endif /* PNG_PROGRESSIVE_READ_SUPPORTED */
  1827.  
  1828. #endif /* PNG_INTERNAL */
  1829.  
  1830. #ifdef __cplusplus
  1831. }
  1832. #endif
  1833.  
  1834. /* do not put anything past this line */
  1835. #endif /* _PNG_H */
  1836.